RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 845268 - mbind reports success, but has no effect
Summary: mbind reports success, but has no effect
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: kernel
Version: 7.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Red Hat Kernel Manager
QA Contact: Red Hat Kernel QE team
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-08-02 14:02 UTC by Jan Stancek
Modified: 2013-01-10 10:14 UTC (History)
6 users (show)

Fixed In Version: kernel-3.7.0-0.30.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-01-10 10:14:27 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Jan Stancek 2012-08-02 14:02:53 UTC
Description of problem:
LTP testcases, which rely on mbind are currently failing. It appears that starting with 3.5.0-0.23.el7 mbind syscall has no effect.

For example:
---------------------- mbind_test.c --------------------
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/mman.h>
#include <numaif.h>
#include <errno.h>

/* gcc mbind_test.c -lnuma -o mbind_test -Wall */
#define MAXNODE 4096

int main()
{
        int ret;
        int len;
        int policy = -1;
        unsigned char *p;
        unsigned long mask[MAXNODE] = { 0 };
        unsigned long retmask[MAXNODE] = { 0 };

        len = getpagesize();
        p = mmap(NULL, len, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
                    0, 0);
        if (p == MAP_FAILED)
                printf("mbind err: %d\n", errno);

        mask[0] = 1;
        ret = mbind(p, len, MPOL_BIND, mask, MAXNODE, 0);
        if (ret < 0)
                printf("mbind err: %d %d\n", ret, errno);
        ret = get_mempolicy(&policy, retmask, MAXNODE, p, MPOL_F_ADDR);
        if (ret < 0)
                printf("get_mempolicy err: %d %d\n", ret, errno);

        if (policy == MPOL_BIND)
                printf("OK\n");
        else
                printf("ERROR: policy is %d\n", policy);

        return 0;
}
---------------------- /mbind_test.c -------------------

strace snippet with 3.3.0-0.20.el7.x86_64 -> OK
...
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0) = 0x7f033809e000
mbind(0x7f033809e000, 4096, MPOL_BIND, {0x0000000000000001, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, ...}, 4096, 0) = 0
get_mempolicy(MPOL_BIND, {0x0000000000000001, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, ...}, 4096, 0x7f033809e000, MPOL_F_ADDR) = 0
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f033809d000
write(1, "OK\n", 3OK

strace snippet with 3.5.0-0.23.el7.x86_64 -> PROBLEM
...
mbind(0x7fb85ee4e000, 4096, MPOL_BIND, {0x0000000000000001, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, ...}, 4096, 0) = 0
get_mempolicy(MPOL_DEFAULT, {000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, ...}, 4096, 0x7fb85ee4e000, MPOL_F_ADDR) = 0
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb85ee4d000
write(1, "ERROR: policy is 0\n", 19ERROR: policy is 0

Version-Release number of selected component (if applicable):
3.5.0-0.23.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. run mbind_test.c in description
  
Actual results:
get_mempolicy() returns different policy than what mbind() has set, returned nodemask is empty

Expected results:
get_mempolicy() returns policy MPOL_BIND, returned nodemask should match the one passed to mbind()

Additional info:
failing LTP testcases include: mbind01, get_mempolicy01, move_pages01

Comment 1 Jan Stancek 2012-08-03 13:15:35 UTC
Reproducible also with upstream 3.6.0-rc1.

Works OK if I revert following commit:
commit 05f144a0d5c2207a0349348127f996e104ad7404
Author: Mel Gorman <mgorman>
Date:   Wed May 23 12:48:13 2012 +0100

    mm: mempolicy: Let vma_merge and vma_split handle vma->vm_policy linkages

    Dave Jones' system call fuzz testing tool "trinity" triggered the
    following bug error with slab debugging enabled

Comment 2 KOSAKI Motohiro 2012-08-06 19:05:55 UTC
I have a patch for upstream. I'll handle this.

thanks.

Comment 3 Jan Stancek 2012-10-03 09:21:45 UTC
Following rebase to 3.6, this issue is still reproducible:

mbind(0x7f2bf165e000, 4096, MPOL_BIND, {0x0000000000000001, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, ...}, 4096, 0) = 0
get_mempolicy(MPOL_DEFAULT, {000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, 000000000000000000, ...}, 4096, 0x7f2bf165e000, MPOL_F_ADDR) = 0

# uname -r
3.6.0-0.27.el7.x86_64

Comment 4 KOSAKI Motohiro 2012-10-09 21:21:29 UTC
merged upstream now. (3.7-rc1).

Comment 5 Jan Stancek 2013-01-10 10:14:27 UTC
# uname -r
3.7.0-0.30.el7.x86_64
# ./mbind_test 
OK

Attached reproducer and LTP testcases (mbind01, get_mempolicy01, move_pages01) passed, closing as CURRENTRELEASE.


Note You need to log in before you can comment on or make changes to this bug.