<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/fs/hugetlbfs, branch v3.4.23</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>hugetlbfs: lockdep annotate root inode properly</title>
<updated>2012-04-26T04:26:34+00:00</updated>
<author>
<name>Aneesh Kumar K.V</name>
<email>aneesh.kumar@linux.vnet.ibm.com</email>
</author>
<published>2012-04-25T23:01:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=65ed76010dfed3cb75c863c9052c367a1bacf80a'/>
<id>65ed76010dfed3cb75c863c9052c367a1bacf80a</id>
<content type='text'>
This fixes the below reported false lockdep warning.  e096d0c7e2e4
("lockdep: Add helper function for dir vs file i_mutex annotation") added
a similar annotation for every other inode in hugetlbfs but missed the
root inode because it was allocated by a separate function.

For HugeTLB fs we allow taking i_mutex in mmap.  HugeTLB fs doesn't
support file write and its file read callback is modified in a05b0855fd
("hugetlbfs: avoid taking i_mutex from hugetlbfs_read()") to not take
i_mutex.  Hence for HugeTLB fs with regular files we really don't take
i_mutex with mmap_sem held.

 ======================================================
 [ INFO: possible circular locking dependency detected ]
 3.4.0-rc1+ #322 Not tainted
 -------------------------------------------------------
 bash/1572 is trying to acquire lock:
  (&amp;mm-&gt;mmap_sem){++++++}, at: [&lt;ffffffff810f1618&gt;] might_fault+0x40/0x90

 but task is already holding lock:
  (&amp;sb-&gt;s_type-&gt;i_mutex_key#12){+.+.+.}, at: [&lt;ffffffff81125f88&gt;] vfs_readdir+0x56/0xa8

 which lock already depends on the new lock.

 the existing dependency chain (in reverse order) is:

 -&gt; #1 (&amp;sb-&gt;s_type-&gt;i_mutex_key#12){+.+.+.}:
        [&lt;ffffffff810a09e5&gt;] lock_acquire+0xd5/0xfa
        [&lt;ffffffff816a2f5e&gt;] __mutex_lock_common+0x48/0x350
        [&lt;ffffffff816a3325&gt;] mutex_lock_nested+0x2a/0x31
        [&lt;ffffffff811fb8e1&gt;] hugetlbfs_file_mmap+0x7d/0x104
        [&lt;ffffffff810f859a&gt;] mmap_region+0x272/0x47d
        [&lt;ffffffff810f8a39&gt;] do_mmap_pgoff+0x294/0x2ee
        [&lt;ffffffff810f8b65&gt;] sys_mmap_pgoff+0xd2/0x10e
        [&lt;ffffffff8103d19e&gt;] sys_mmap+0x1d/0x1f
        [&lt;ffffffff816a5922&gt;] system_call_fastpath+0x16/0x1b

 -&gt; #0 (&amp;mm-&gt;mmap_sem){++++++}:
        [&lt;ffffffff810a0256&gt;] __lock_acquire+0xa81/0xd75
        [&lt;ffffffff810a09e5&gt;] lock_acquire+0xd5/0xfa
        [&lt;ffffffff810f1645&gt;] might_fault+0x6d/0x90
        [&lt;ffffffff81125d62&gt;] filldir+0x6a/0xc2
        [&lt;ffffffff81133a83&gt;] dcache_readdir+0x5c/0x222
        [&lt;ffffffff81125fa8&gt;] vfs_readdir+0x76/0xa8
        [&lt;ffffffff811260b6&gt;] sys_getdents+0x79/0xc9
        [&lt;ffffffff816a5922&gt;] system_call_fastpath+0x16/0x1b

 other info that might help us debug this:

  Possible unsafe locking scenario:

        CPU0                    CPU1
        ----                    ----
   lock(&amp;sb-&gt;s_type-&gt;i_mutex_key#12);
                                lock(&amp;mm-&gt;mmap_sem);
                                lock(&amp;sb-&gt;s_type-&gt;i_mutex_key#12);
   lock(&amp;mm-&gt;mmap_sem);

  *** DEADLOCK ***

 1 lock held by bash/1572:
  #0:  (&amp;sb-&gt;s_type-&gt;i_mutex_key#12){+.+.+.}, at: [&lt;ffffffff81125f88&gt;] vfs_readdir+0x56/0xa8

 stack backtrace:
 Pid: 1572, comm: bash Not tainted 3.4.0-rc1+ #322
 Call Trace:
  [&lt;ffffffff81699a3c&gt;] print_circular_bug+0x1f8/0x209
  [&lt;ffffffff810a0256&gt;] __lock_acquire+0xa81/0xd75
  [&lt;ffffffff810f38aa&gt;] ? handle_pte_fault+0x5ff/0x614
  [&lt;ffffffff8109e622&gt;] ? mark_lock+0x2d/0x258
  [&lt;ffffffff810f1618&gt;] ? might_fault+0x40/0x90
  [&lt;ffffffff810a09e5&gt;] lock_acquire+0xd5/0xfa
  [&lt;ffffffff810f1618&gt;] ? might_fault+0x40/0x90
  [&lt;ffffffff816a3249&gt;] ? __mutex_lock_common+0x333/0x350
  [&lt;ffffffff810f1645&gt;] might_fault+0x6d/0x90
  [&lt;ffffffff810f1618&gt;] ? might_fault+0x40/0x90
  [&lt;ffffffff81125d62&gt;] filldir+0x6a/0xc2
  [&lt;ffffffff81133a83&gt;] dcache_readdir+0x5c/0x222
  [&lt;ffffffff81125cf8&gt;] ? sys_ioctl+0x74/0x74
  [&lt;ffffffff81125cf8&gt;] ? sys_ioctl+0x74/0x74
  [&lt;ffffffff81125cf8&gt;] ? sys_ioctl+0x74/0x74
  [&lt;ffffffff81125fa8&gt;] vfs_readdir+0x76/0xa8
  [&lt;ffffffff811260b6&gt;] sys_getdents+0x79/0xc9
  [&lt;ffffffff816a5922&gt;] system_call_fastpath+0x16/0x1b

Signed-off-by: Aneesh Kumar K.V &lt;aneesh.kumar@linux.vnet.ibm.com&gt;
Cc: Dave Jones &lt;davej@redhat.com&gt;
Cc: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Cc: Josh Boyer &lt;jwboyer@redhat.com&gt;
Cc: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Cc: Mimi Zohar &lt;zohar@linux.vnet.ibm.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This fixes the below reported false lockdep warning.  e096d0c7e2e4
("lockdep: Add helper function for dir vs file i_mutex annotation") added
a similar annotation for every other inode in hugetlbfs but missed the
root inode because it was allocated by a separate function.

For HugeTLB fs we allow taking i_mutex in mmap.  HugeTLB fs doesn't
support file write and its file read callback is modified in a05b0855fd
("hugetlbfs: avoid taking i_mutex from hugetlbfs_read()") to not take
i_mutex.  Hence for HugeTLB fs with regular files we really don't take
i_mutex with mmap_sem held.

 ======================================================
 [ INFO: possible circular locking dependency detected ]
 3.4.0-rc1+ #322 Not tainted
 -------------------------------------------------------
 bash/1572 is trying to acquire lock:
  (&amp;mm-&gt;mmap_sem){++++++}, at: [&lt;ffffffff810f1618&gt;] might_fault+0x40/0x90

 but task is already holding lock:
  (&amp;sb-&gt;s_type-&gt;i_mutex_key#12){+.+.+.}, at: [&lt;ffffffff81125f88&gt;] vfs_readdir+0x56/0xa8

 which lock already depends on the new lock.

 the existing dependency chain (in reverse order) is:

 -&gt; #1 (&amp;sb-&gt;s_type-&gt;i_mutex_key#12){+.+.+.}:
        [&lt;ffffffff810a09e5&gt;] lock_acquire+0xd5/0xfa
        [&lt;ffffffff816a2f5e&gt;] __mutex_lock_common+0x48/0x350
        [&lt;ffffffff816a3325&gt;] mutex_lock_nested+0x2a/0x31
        [&lt;ffffffff811fb8e1&gt;] hugetlbfs_file_mmap+0x7d/0x104
        [&lt;ffffffff810f859a&gt;] mmap_region+0x272/0x47d
        [&lt;ffffffff810f8a39&gt;] do_mmap_pgoff+0x294/0x2ee
        [&lt;ffffffff810f8b65&gt;] sys_mmap_pgoff+0xd2/0x10e
        [&lt;ffffffff8103d19e&gt;] sys_mmap+0x1d/0x1f
        [&lt;ffffffff816a5922&gt;] system_call_fastpath+0x16/0x1b

 -&gt; #0 (&amp;mm-&gt;mmap_sem){++++++}:
        [&lt;ffffffff810a0256&gt;] __lock_acquire+0xa81/0xd75
        [&lt;ffffffff810a09e5&gt;] lock_acquire+0xd5/0xfa
        [&lt;ffffffff810f1645&gt;] might_fault+0x6d/0x90
        [&lt;ffffffff81125d62&gt;] filldir+0x6a/0xc2
        [&lt;ffffffff81133a83&gt;] dcache_readdir+0x5c/0x222
        [&lt;ffffffff81125fa8&gt;] vfs_readdir+0x76/0xa8
        [&lt;ffffffff811260b6&gt;] sys_getdents+0x79/0xc9
        [&lt;ffffffff816a5922&gt;] system_call_fastpath+0x16/0x1b

 other info that might help us debug this:

  Possible unsafe locking scenario:

        CPU0                    CPU1
        ----                    ----
   lock(&amp;sb-&gt;s_type-&gt;i_mutex_key#12);
                                lock(&amp;mm-&gt;mmap_sem);
                                lock(&amp;sb-&gt;s_type-&gt;i_mutex_key#12);
   lock(&amp;mm-&gt;mmap_sem);

  *** DEADLOCK ***

 1 lock held by bash/1572:
  #0:  (&amp;sb-&gt;s_type-&gt;i_mutex_key#12){+.+.+.}, at: [&lt;ffffffff81125f88&gt;] vfs_readdir+0x56/0xa8

 stack backtrace:
 Pid: 1572, comm: bash Not tainted 3.4.0-rc1+ #322
 Call Trace:
  [&lt;ffffffff81699a3c&gt;] print_circular_bug+0x1f8/0x209
  [&lt;ffffffff810a0256&gt;] __lock_acquire+0xa81/0xd75
  [&lt;ffffffff810f38aa&gt;] ? handle_pte_fault+0x5ff/0x614
  [&lt;ffffffff8109e622&gt;] ? mark_lock+0x2d/0x258
  [&lt;ffffffff810f1618&gt;] ? might_fault+0x40/0x90
  [&lt;ffffffff810a09e5&gt;] lock_acquire+0xd5/0xfa
  [&lt;ffffffff810f1618&gt;] ? might_fault+0x40/0x90
  [&lt;ffffffff816a3249&gt;] ? __mutex_lock_common+0x333/0x350
  [&lt;ffffffff810f1645&gt;] might_fault+0x6d/0x90
  [&lt;ffffffff810f1618&gt;] ? might_fault+0x40/0x90
  [&lt;ffffffff81125d62&gt;] filldir+0x6a/0xc2
  [&lt;ffffffff81133a83&gt;] dcache_readdir+0x5c/0x222
  [&lt;ffffffff81125cf8&gt;] ? sys_ioctl+0x74/0x74
  [&lt;ffffffff81125cf8&gt;] ? sys_ioctl+0x74/0x74
  [&lt;ffffffff81125cf8&gt;] ? sys_ioctl+0x74/0x74
  [&lt;ffffffff81125fa8&gt;] vfs_readdir+0x76/0xa8
  [&lt;ffffffff811260b6&gt;] sys_getdents+0x79/0xc9
  [&lt;ffffffff816a5922&gt;] system_call_fastpath+0x16/0x1b

Signed-off-by: Aneesh Kumar K.V &lt;aneesh.kumar@linux.vnet.ibm.com&gt;
Cc: Dave Jones &lt;davej@redhat.com&gt;
Cc: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Cc: Josh Boyer &lt;jwboyer@redhat.com&gt;
Cc: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Cc: Mimi Zohar &lt;zohar@linux.vnet.ibm.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>hugetlbfs: remove unregister_filesystem() when initializing module</title>
<updated>2012-04-05T22:25:50+00:00</updated>
<author>
<name>Hillf Danton</name>
<email>dhillf@gmail.com</email>
</author>
<published>2012-04-05T21:25:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=7563ec4c211ba59c2331dc6b94a068250345c387'/>
<id>7563ec4c211ba59c2331dc6b94a068250345c387</id>
<content type='text'>
It was introduced by d1d5e05ffdc1 ("hugetlbfs: return error code when
initializing module") but as Al pointed out, is a bad idea.

Quoted comments from Al:
 "Note that unregister_filesystem() in module init is *always* wrong;
  it's not an issue here (it's done too early to care about and
  realistically the box is not going anywhere - it'll panic when attempt
  to exec /sbin/init fails, if not earlier), but it's a damn bad
  example.

  Consider a normal fs module.  Somebody loads it and in parallel with
  that we get a mount attempt on that fs type.  It comes between
  register and failure exits that causes unregister; at that point we
  are screwed since grabbing a reference to module as done by mount is
  enough to prevent exit, but not to prevent the failure of init.  As
  the result, module will get freed when init fails, mounted fs of that
  type be damned."

So remove it.

Signed-off-by: Hillf Danton &lt;dhillf@gmail.com&gt;
Cc: David Rientjes &lt;rientjes@google.com&gt;
Cc: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
It was introduced by d1d5e05ffdc1 ("hugetlbfs: return error code when
initializing module") but as Al pointed out, is a bad idea.

Quoted comments from Al:
 "Note that unregister_filesystem() in module init is *always* wrong;
  it's not an issue here (it's done too early to care about and
  realistically the box is not going anywhere - it'll panic when attempt
  to exec /sbin/init fails, if not earlier), but it's a damn bad
  example.

  Consider a normal fs module.  Somebody loads it and in parallel with
  that we get a mount attempt on that fs type.  It comes between
  register and failure exits that causes unregister; at that point we
  are screwed since grabbing a reference to module as done by mount is
  enough to prevent exit, but not to prevent the failure of init.  As
  the result, module will get freed when init fails, mounted fs of that
  type be damned."

So remove it.

Signed-off-by: Hillf Danton &lt;dhillf@gmail.com&gt;
Cc: David Rientjes &lt;rientjes@google.com&gt;
Cc: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge branch 'akpm' (Andrew's patch-bomb)</title>
<updated>2012-03-22T16:04:48+00:00</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2012-03-22T16:04:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=95211279c5ad00a317c98221d7e4365e02f20836'/>
<id>95211279c5ad00a317c98221d7e4365e02f20836</id>
<content type='text'>
Merge first batch of patches from Andrew Morton:
 "A few misc things and all the MM queue"

* emailed from Andrew Morton &lt;akpm@linux-foundation.org&gt;: (92 commits)
  memcg: avoid THP split in task migration
  thp: add HPAGE_PMD_* definitions for !CONFIG_TRANSPARENT_HUGEPAGE
  memcg: clean up existing move charge code
  mm/memcontrol.c: remove unnecessary 'break' in mem_cgroup_read()
  mm/memcontrol.c: remove redundant BUG_ON() in mem_cgroup_usage_unregister_event()
  mm/memcontrol.c: s/stealed/stolen/
  memcg: fix performance of mem_cgroup_begin_update_page_stat()
  memcg: remove PCG_FILE_MAPPED
  memcg: use new logic for page stat accounting
  memcg: remove PCG_MOVE_LOCK flag from page_cgroup
  memcg: simplify move_account() check
  memcg: remove EXPORT_SYMBOL(mem_cgroup_update_page_stat)
  memcg: kill dead prev_priority stubs
  memcg: remove PCG_CACHE page_cgroup flag
  memcg: let css_get_next() rely upon rcu_read_lock()
  cgroup: revert ss_id_lock to spinlock
  idr: make idr_get_next() good for rcu_read_lock()
  memcg: remove unnecessary thp check in page stat accounting
  memcg: remove redundant returns
  memcg: enum lru_list lru
  ...
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Merge first batch of patches from Andrew Morton:
 "A few misc things and all the MM queue"

* emailed from Andrew Morton &lt;akpm@linux-foundation.org&gt;: (92 commits)
  memcg: avoid THP split in task migration
  thp: add HPAGE_PMD_* definitions for !CONFIG_TRANSPARENT_HUGEPAGE
  memcg: clean up existing move charge code
  mm/memcontrol.c: remove unnecessary 'break' in mem_cgroup_read()
  mm/memcontrol.c: remove redundant BUG_ON() in mem_cgroup_usage_unregister_event()
  mm/memcontrol.c: s/stealed/stolen/
  memcg: fix performance of mem_cgroup_begin_update_page_stat()
  memcg: remove PCG_FILE_MAPPED
  memcg: use new logic for page stat accounting
  memcg: remove PCG_MOVE_LOCK flag from page_cgroup
  memcg: simplify move_account() check
  memcg: remove EXPORT_SYMBOL(mem_cgroup_update_page_stat)
  memcg: kill dead prev_priority stubs
  memcg: remove PCG_CACHE page_cgroup flag
  memcg: let css_get_next() rely upon rcu_read_lock()
  cgroup: revert ss_id_lock to spinlock
  idr: make idr_get_next() good for rcu_read_lock()
  memcg: remove unnecessary thp check in page stat accounting
  memcg: remove redundant returns
  memcg: enum lru_list lru
  ...
</pre>
</div>
</content>
</entry>
<entry>
<title>hugetlbfs: return error code when initializing module</title>
<updated>2012-03-22T00:55:00+00:00</updated>
<author>
<name>Hillf Danton</name>
<email>dhillf@gmail.com</email>
</author>
<published>2012-03-21T23:34:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=d1d5e05ffdc110021ae7937802e88ae0d223dcdc'/>
<id>d1d5e05ffdc110021ae7937802e88ae0d223dcdc</id>
<content type='text'>
Return an errno upon failure to create inode kmem cache, and unregister
the FS upon failure to mount.

[akpm@linux-foundation.org: remove unneeded test of `error']
Signed-off-by: Hillf Danton &lt;dhillf@gmail.com&gt;
Acked-by: David Rientjes &lt;rientjes@google.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Return an errno upon failure to create inode kmem cache, and unregister
the FS upon failure to mount.

[akpm@linux-foundation.org: remove unneeded test of `error']
Signed-off-by: Hillf Danton &lt;dhillf@gmail.com&gt;
Acked-by: David Rientjes &lt;rientjes@google.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>hugetlbfs: fix alignment of huge page requests</title>
<updated>2012-03-22T00:54:59+00:00</updated>
<author>
<name>Steven Truelove</name>
<email>steven.truelove@utoronto.ca</email>
</author>
<published>2012-03-21T23:34:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=40716e29243de46720e5773797791466c28904ec'/>
<id>40716e29243de46720e5773797791466c28904ec</id>
<content type='text'>
When calling shmget() with SHM_HUGETLB, shmget aligns the request size to
PAGE_SIZE, but this is not sufficient.

Modify hugetlb_file_setup() to align requests to the huge page size, and
to accept an address argument so that all alignment checks can be
performed in hugetlb_file_setup(), rather than in its callers.  Change
newseg() and mmap_pgoff() to match the new prototype and eliminate a now
redundant alignment check.

[akpm@linux-foundation.org: fix build]
Signed-off-by: Steven Truelove &lt;steven.truelove@utoronto.ca&gt;
Cc: Hugh Dickins &lt;hughd@google.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When calling shmget() with SHM_HUGETLB, shmget aligns the request size to
PAGE_SIZE, but this is not sufficient.

Modify hugetlb_file_setup() to align requests to the huge page size, and
to accept an address argument so that all alignment checks can be
performed in hugetlb_file_setup(), rather than in its callers.  Change
newseg() and mmap_pgoff() to match the new prototype and eliminate a now
redundant alignment check.

[akpm@linux-foundation.org: fix build]
Signed-off-by: Steven Truelove &lt;steven.truelove@utoronto.ca&gt;
Cc: Hugh Dickins &lt;hughd@google.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>mm, hugetlb: add thread name and pid to SHM_HUGETLB mlock rlimit warning</title>
<updated>2012-03-22T00:54:59+00:00</updated>
<author>
<name>David Rientjes</name>
<email>rientjes@google.com</email>
</author>
<published>2012-03-21T23:34:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=21a3c273f88c9cbbaf7e14505df0131d95c8f262'/>
<id>21a3c273f88c9cbbaf7e14505df0131d95c8f262</id>
<content type='text'>
Add the thread name and pid of the application that is allocating shm
segments with MAP_HUGETLB without being a part of
/proc/sys/vm/hugetlb_shm_group or having CAP_IPC_LOCK.

This identifies the application so it may be fixed by avoiding using the
deprecated exception (see Documentation/feature-removal-schedule.txt).

Signed-off-by: David Rientjes &lt;rientjes@google.com&gt;
Cc: Dave Jones &lt;davej@redhat.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add the thread name and pid of the application that is allocating shm
segments with MAP_HUGETLB without being a part of
/proc/sys/vm/hugetlb_shm_group or having CAP_IPC_LOCK.

This identifies the application so it may be fixed by avoiding using the
deprecated exception (see Documentation/feature-removal-schedule.txt).

Signed-off-by: David Rientjes &lt;rientjes@google.com&gt;
Cc: Dave Jones &lt;davej@redhat.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>hugepages: fix use after free bug in "quota" handling</title>
<updated>2012-03-22T00:54:59+00:00</updated>
<author>
<name>David Gibson</name>
<email>david@gibson.dropbear.id.au</email>
</author>
<published>2012-03-21T23:34:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=90481622d75715bfcb68501280a917dbfe516029'/>
<id>90481622d75715bfcb68501280a917dbfe516029</id>
<content type='text'>
hugetlbfs_{get,put}_quota() are badly named.  They don't interact with the
general quota handling code, and they don't much resemble its behaviour.
Rather than being about maintaining limits on on-disk block usage by
particular users, they are instead about maintaining limits on in-memory
page usage (including anonymous MAP_PRIVATE copied-on-write pages)
associated with a particular hugetlbfs filesystem instance.

Worse, they work by having callbacks to the hugetlbfs filesystem code from
the low-level page handling code, in particular from free_huge_page().
This is a layering violation of itself, but more importantly, if the
kernel does a get_user_pages() on hugepages (which can happen from KVM
amongst others), then the free_huge_page() can be delayed until after the
associated inode has already been freed.  If an unmount occurs at the
wrong time, even the hugetlbfs superblock where the "quota" limits are
stored may have been freed.

Andrew Barry proposed a patch to fix this by having hugepages, instead of
storing a pointer to their address_space and reaching the superblock from
there, had the hugepages store pointers directly to the superblock,
bumping the reference count as appropriate to avoid it being freed.
Andrew Morton rejected that version, however, on the grounds that it made
the existing layering violation worse.

This is a reworked version of Andrew's patch, which removes the extra, and
some of the existing, layering violation.  It works by introducing the
concept of a hugepage "subpool" at the lower hugepage mm layer - that is a
finite logical pool of hugepages to allocate from.  hugetlbfs now creates
a subpool for each filesystem instance with a page limit set, and a
pointer to the subpool gets added to each allocated hugepage, instead of
the address_space pointer used now.  The subpool has its own lifetime and
is only freed once all pages in it _and_ all other references to it (i.e.
superblocks) are gone.

subpools are optional - a NULL subpool pointer is taken by the code to
mean that no subpool limits are in effect.

Previous discussion of this bug found in:  "Fix refcounting in hugetlbfs
quota handling.". See:  https://lkml.org/lkml/2011/8/11/28 or
http://marc.info/?l=linux-mm&amp;m=126928970510627&amp;w=1

v2: Fixed a bug spotted by Hillf Danton, and removed the extra parameter to
alloc_huge_page() - since it already takes the vma, it is not necessary.

Signed-off-by: Andrew Barry &lt;abarry@cray.com&gt;
Signed-off-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Cc: Hugh Dickins &lt;hughd@google.com&gt;
Cc: Mel Gorman &lt;mgorman@suse.de&gt;
Cc: Minchan Kim &lt;minchan.kim@gmail.com&gt;
Cc: Hillf Danton &lt;dhillf@gmail.com&gt;
Cc: Paul Mackerras &lt;paulus@samba.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
hugetlbfs_{get,put}_quota() are badly named.  They don't interact with the
general quota handling code, and they don't much resemble its behaviour.
Rather than being about maintaining limits on on-disk block usage by
particular users, they are instead about maintaining limits on in-memory
page usage (including anonymous MAP_PRIVATE copied-on-write pages)
associated with a particular hugetlbfs filesystem instance.

Worse, they work by having callbacks to the hugetlbfs filesystem code from
the low-level page handling code, in particular from free_huge_page().
This is a layering violation of itself, but more importantly, if the
kernel does a get_user_pages() on hugepages (which can happen from KVM
amongst others), then the free_huge_page() can be delayed until after the
associated inode has already been freed.  If an unmount occurs at the
wrong time, even the hugetlbfs superblock where the "quota" limits are
stored may have been freed.

Andrew Barry proposed a patch to fix this by having hugepages, instead of
storing a pointer to their address_space and reaching the superblock from
there, had the hugepages store pointers directly to the superblock,
bumping the reference count as appropriate to avoid it being freed.
Andrew Morton rejected that version, however, on the grounds that it made
the existing layering violation worse.

This is a reworked version of Andrew's patch, which removes the extra, and
some of the existing, layering violation.  It works by introducing the
concept of a hugepage "subpool" at the lower hugepage mm layer - that is a
finite logical pool of hugepages to allocate from.  hugetlbfs now creates
a subpool for each filesystem instance with a page limit set, and a
pointer to the subpool gets added to each allocated hugepage, instead of
the address_space pointer used now.  The subpool has its own lifetime and
is only freed once all pages in it _and_ all other references to it (i.e.
superblocks) are gone.

subpools are optional - a NULL subpool pointer is taken by the code to
mean that no subpool limits are in effect.

Previous discussion of this bug found in:  "Fix refcounting in hugetlbfs
quota handling.". See:  https://lkml.org/lkml/2011/8/11/28 or
http://marc.info/?l=linux-mm&amp;m=126928970510627&amp;w=1

v2: Fixed a bug spotted by Hillf Danton, and removed the extra parameter to
alloc_huge_page() - since it already takes the vma, it is not necessary.

Signed-off-by: Andrew Barry &lt;abarry@cray.com&gt;
Signed-off-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Cc: Hugh Dickins &lt;hughd@google.com&gt;
Cc: Mel Gorman &lt;mgorman@suse.de&gt;
Cc: Minchan Kim &lt;minchan.kim@gmail.com&gt;
Cc: Hillf Danton &lt;dhillf@gmail.com&gt;
Cc: Paul Mackerras &lt;paulus@samba.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>hugetlb: cleanup hugetlb.h</title>
<updated>2012-03-22T00:54:59+00:00</updated>
<author>
<name>David Gibson</name>
<email>david@gibson.dropbear.id.au</email>
</author>
<published>2012-03-21T23:34:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=a1d776ee3147cec2a54a645e92eb2e3e2f65a137'/>
<id>a1d776ee3147cec2a54a645e92eb2e3e2f65a137</id>
<content type='text'>
Make a couple of small cleanups to linux/include/hugetlb.h.  The
set_file_hugepages() function, which was not used anywhere is removed,
and the hugetlbfs_config and hugetlbfs_inode_info structures with its
HUGETLBFS_I helper function are moved into inode.c, the only place they
were used.

These structures are really linked to the hugetlbfs filesystem
specifically not to hugepage mm handling in general, so they belong in
the filesystem code not in a generally available header.

It would be nice to move the hugetlbfs_sb_info (superblock) structure in
there as well, but it's currently needed in a number of places via the
hstate_vma() and hstate_inode().

Signed-off-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Cc: Hugh Dickins &lt;hughd@google.com&gt;
Cc: Paul Mackerras &lt;paulus@samba.org&gt;
Cc: Andrew Barry &lt;abarry@cray.com&gt;
Cc: Mel Gorman &lt;mgorman@suse.de&gt;
Cc: Minchan Kim &lt;minchan.kim@gmail.com&gt;
Cc: Hillf Danton &lt;dhillf@gmail.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Make a couple of small cleanups to linux/include/hugetlb.h.  The
set_file_hugepages() function, which was not used anywhere is removed,
and the hugetlbfs_config and hugetlbfs_inode_info structures with its
HUGETLBFS_I helper function are moved into inode.c, the only place they
were used.

These structures are really linked to the hugetlbfs filesystem
specifically not to hugepage mm handling in general, so they belong in
the filesystem code not in a generally available header.

It would be nice to move the hugetlbfs_sb_info (superblock) structure in
there as well, but it's currently needed in a number of places via the
hstate_vma() and hstate_inode().

Signed-off-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Cc: Hugh Dickins &lt;hughd@google.com&gt;
Cc: Paul Mackerras &lt;paulus@samba.org&gt;
Cc: Andrew Barry &lt;abarry@cray.com&gt;
Cc: Mel Gorman &lt;mgorman@suse.de&gt;
Cc: Minchan Kim &lt;minchan.kim@gmail.com&gt;
Cc: Hillf Danton &lt;dhillf@gmail.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>hugetlbfs: avoid taking i_mutex from hugetlbfs_read()</title>
<updated>2012-03-22T00:54:58+00:00</updated>
<author>
<name>Aneesh Kumar K.V</name>
<email>aneesh.kumar@linux.vnet.ibm.com</email>
</author>
<published>2012-03-21T23:34:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=a05b0855fd15504972dba2358e5faa172a1e50ba'/>
<id>a05b0855fd15504972dba2358e5faa172a1e50ba</id>
<content type='text'>
Taking i_mutex in hugetlbfs_read() can result in deadlock with mmap as
explained below

 Thread A:
  read() on hugetlbfs
   hugetlbfs_read() called
    i_mutex grabbed
     hugetlbfs_read_actor() called
      __copy_to_user() called
       page fault is triggered
 Thread B, sharing address space with A:
  mmap() the same file
   -&gt;mmap_sem is grabbed on task_B-&gt;mm-&gt;mmap_sem
    hugetlbfs_file_mmap() is called
     attempt to grab -&gt;i_mutex and block waiting for A to give it up
 Thread A:
  pagefault handled blocked on attempt to grab task_A-&gt;mm-&gt;mmap_sem,
 which happens to be the same thing as task_B-&gt;mm-&gt;mmap_sem.  Block waiting
 for B to give it up.

AFAIU the i_mutex locking was added to hugetlbfs_read() as per
http://lkml.indiana.edu/hypermail/linux/kernel/0707.2/3066.html to take
care of the race between truncate and read.  This patch fixes this by
looking at page-&gt;mapping under lock_page() (find_lock_page()) to ensure
that the inode didn't get truncated in the range during a parallel read.

Ideally we can extend the patch to make sure we don't increase i_size in
mmap.  But that will break userspace, because applications will now have
to use truncate(2) to increase i_size in hugetlbfs.

Based on the original patch from Hillf Danton.

Signed-off-by: Aneesh Kumar K.V &lt;aneesh.kumar@linux.vnet.ibm.com&gt;
Cc: Hillf Danton &lt;dhillf@gmail.com&gt;
Cc: KAMEZAWA Hiroyuki &lt;kamezawa.hiroyu@jp.fujitsu.com&gt;
Cc: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Cc: Hugh Dickins &lt;hughd@google.com&gt;
Cc: &lt;stable@kernel.org&gt;		[everything after 2007 :)]
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Taking i_mutex in hugetlbfs_read() can result in deadlock with mmap as
explained below

 Thread A:
  read() on hugetlbfs
   hugetlbfs_read() called
    i_mutex grabbed
     hugetlbfs_read_actor() called
      __copy_to_user() called
       page fault is triggered
 Thread B, sharing address space with A:
  mmap() the same file
   -&gt;mmap_sem is grabbed on task_B-&gt;mm-&gt;mmap_sem
    hugetlbfs_file_mmap() is called
     attempt to grab -&gt;i_mutex and block waiting for A to give it up
 Thread A:
  pagefault handled blocked on attempt to grab task_A-&gt;mm-&gt;mmap_sem,
 which happens to be the same thing as task_B-&gt;mm-&gt;mmap_sem.  Block waiting
 for B to give it up.

AFAIU the i_mutex locking was added to hugetlbfs_read() as per
http://lkml.indiana.edu/hypermail/linux/kernel/0707.2/3066.html to take
care of the race between truncate and read.  This patch fixes this by
looking at page-&gt;mapping under lock_page() (find_lock_page()) to ensure
that the inode didn't get truncated in the range during a parallel read.

Ideally we can extend the patch to make sure we don't increase i_size in
mmap.  But that will break userspace, because applications will now have
to use truncate(2) to increase i_size in hugetlbfs.

Based on the original patch from Hillf Danton.

Signed-off-by: Aneesh Kumar K.V &lt;aneesh.kumar@linux.vnet.ibm.com&gt;
Cc: Hillf Danton &lt;dhillf@gmail.com&gt;
Cc: KAMEZAWA Hiroyuki &lt;kamezawa.hiroyu@jp.fujitsu.com&gt;
Cc: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Cc: Hugh Dickins &lt;hughd@google.com&gt;
Cc: &lt;stable@kernel.org&gt;		[everything after 2007 :)]
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>hugetlbfs: fix hugetlb_get_unmapped_area()</title>
<updated>2012-03-22T00:54:56+00:00</updated>
<author>
<name>Xiao Guangrong</name>
<email>xiaoguangrong@linux.vnet.ibm.com</email>
</author>
<published>2012-03-21T23:33:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=4bfc130d5afa28395288d1b57092906349604b41'/>
<id>4bfc130d5afa28395288d1b57092906349604b41</id>
<content type='text'>
Use/update cached_hole_size and free_area_cache properly to speedup
finding of a free region.

Signed-off-by: Xiao Guangrong &lt;xiaoguangrong@linux.vnet.ibm.com&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: Ingo Molnar &lt;mingo@redhat.com&gt;
Cc: "H. Peter Anvin" &lt;hpa@zytor.com&gt;
Cc: Michal Hocko &lt;mhocko@suse.cz&gt;
Cc: Hillf Danton &lt;dhillf@gmail.com&gt;
Cc: Andrea Arcangeli &lt;aarcange@redhat.com&gt;
Cc: KAMEZAWA Hiroyuki &lt;kamezawa.hiroyu@jp.fujitsu.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Use/update cached_hole_size and free_area_cache properly to speedup
finding of a free region.

Signed-off-by: Xiao Guangrong &lt;xiaoguangrong@linux.vnet.ibm.com&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: Ingo Molnar &lt;mingo@redhat.com&gt;
Cc: "H. Peter Anvin" &lt;hpa@zytor.com&gt;
Cc: Michal Hocko &lt;mhocko@suse.cz&gt;
Cc: Hillf Danton &lt;dhillf@gmail.com&gt;
Cc: Andrea Arcangeli &lt;aarcange@redhat.com&gt;
Cc: KAMEZAWA Hiroyuki &lt;kamezawa.hiroyu@jp.fujitsu.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
</feed>
