<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/fs/seq_file.c, branch v3.19</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v3.19</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v3.19'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2014-12-13T20:42:49Z</updated>
<entry>
<title>fs, seq_file: fallback to vmalloc instead of oom kill processes</title>
<updated>2014-12-13T20:42:49Z</updated>
<author>
<name>David Rientjes</name>
<email>rientjes@google.com</email>
</author>
<published>2014-12-13T00:56:16Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=5cec38ac866bfb8775638e71a86e4d8cac30caae'/>
<id>urn:sha1:5cec38ac866bfb8775638e71a86e4d8cac30caae</id>
<content type='text'>
Since commit 058504edd026 ("fs/seq_file: fallback to vmalloc allocation"),
seq_buf_alloc() falls back to vmalloc() when the kmalloc() for contiguous
memory fails.  This was done to address order-4 slab allocations for
reading /proc/stat on large machines and noticed because
PAGE_ALLOC_COSTLY_ORDER &lt; 4, so there is no infinite loop in the page
allocator when allocating new slab for such high-order allocations.

Contiguous memory isn't necessary for caller of seq_buf_alloc(), however.
Other GFP_KERNEL high-order allocations that are &lt;=
PAGE_ALLOC_COSTLY_ORDER will simply loop forever in the page allocator and
oom kill processes as a result.

We don't want to kill processes so that we can allocate contiguous memory
in situations when contiguous memory isn't necessary.

This patch does the kmalloc() allocation with __GFP_NORETRY for high-order
allocations.  This still utilizes memory compaction and direct reclaim in
the allocation path, the only difference is that it will fail immediately
instead of oom kill processes when out of memory.

[akpm@linux-foundation.org: add comment]
Signed-off-by: David Rientjes &lt;rientjes@google.com&gt;
Cc: Heiko Carstens &lt;heiko.carstens@de.ibm.com&gt;
Cc: Christoph Hellwig &lt;hch@infradead.org&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>
</entry>
<entry>
<title>seq_file: Rename seq_overflow() to seq_has_overflowed() and make public</title>
<updated>2014-10-30T00:26:06Z</updated>
<author>
<name>Joe Perches</name>
<email>joe@perches.com</email>
</author>
<published>2014-09-29T23:08:21Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=1f33c41c03daece85a84b8dcea5733f3efe3e2b0'/>
<id>urn:sha1:1f33c41c03daece85a84b8dcea5733f3efe3e2b0</id>
<content type='text'>
The return values of seq_printf/puts/putc are frequently misused.

Start down a path to remove all the return value uses of these
functions.

Move the seq_overflow() to a global inlined function called
seq_has_overflowed() that can be used by the users of seq_file() calls.

Update the documentation to not show return types for seq_printf
et al.  Add a description of seq_has_overflowed().

Link: http://lkml.kernel.org/p/848ac7e3d1c31cddf638a8526fa3c59fa6fdeb8a.1412031505.git.joe@perches.com

Cc: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Signed-off-by: Joe Perches &lt;joe@perches.com&gt;
[ Reworked the original patch from Joe ]
Signed-off-by: Steven Rostedt &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>fs/seq_file: fallback to vmalloc allocation</title>
<updated>2014-07-03T16:21:54Z</updated>
<author>
<name>Heiko Carstens</name>
<email>heiko.carstens@de.ibm.com</email>
</author>
<published>2014-07-02T22:22:37Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=058504edd02667eef8fac9be27ab3ea74332e9b4'/>
<id>urn:sha1:058504edd02667eef8fac9be27ab3ea74332e9b4</id>
<content type='text'>
There are a couple of seq_files which use the single_open() interface.
This interface requires that the whole output must fit into a single
buffer.

E.g.  for /proc/stat allocation failures have been observed because an
order-4 memory allocation failed due to memory fragmentation.  In such
situations reading /proc/stat is not possible anymore.

Therefore change the seq_file code to fallback to vmalloc allocations
which will usually result in a couple of order-0 allocations and hence
also work if memory is fragmented.

For reference a call trace where reading from /proc/stat failed:

  sadc: page allocation failure: order:4, mode:0x1040d0
  CPU: 1 PID: 192063 Comm: sadc Not tainted 3.10.0-123.el7.s390x #1
  [...]
  Call Trace:
    show_stack+0x6c/0xe8
    warn_alloc_failed+0xd6/0x138
    __alloc_pages_nodemask+0x9da/0xb68
    __get_free_pages+0x2e/0x58
    kmalloc_order_trace+0x44/0xc0
    stat_open+0x5a/0xd8
    proc_reg_open+0x8a/0x140
    do_dentry_open+0x1bc/0x2c8
    finish_open+0x46/0x60
    do_last+0x382/0x10d0
    path_openat+0xc8/0x4f8
    do_filp_open+0x46/0xa8
    do_sys_open+0x114/0x1f0
    sysc_tracego+0x14/0x1a

Signed-off-by: Heiko Carstens &lt;heiko.carstens@de.ibm.com&gt;
Tested-by: David Rientjes &lt;rientjes@google.com&gt;
Cc: Ian Kent &lt;raven@themaw.net&gt;
Cc: Hendrik Brueckner &lt;brueckner@linux.vnet.ibm.com&gt;
Cc: Thorsten Diehl &lt;thorsten.diehl@de.ibm.com&gt;
Cc: Andrea Righi &lt;andrea@betterlinux.com&gt;
Cc: Christoph Hellwig &lt;hch@infradead.org&gt;
Cc: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Cc: Stefan Bader &lt;stefan.bader@canonical.com&gt;
Cc: &lt;stable@vger.kernel.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>
</entry>
<entry>
<title>seq_file: always clear m-&gt;count when we free m-&gt;buf</title>
<updated>2013-11-19T03:07:53Z</updated>
<author>
<name>Al Viro</name>
<email>viro@ZenIV.linux.org.uk</email>
</author>
<published>2013-11-19T01:20:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=801a76050bcf8d4e500eb8d048ff6265f37a61c8'/>
<id>urn:sha1:801a76050bcf8d4e500eb8d048ff6265f37a61c8</id>
<content type='text'>
Once we'd freed m-&gt;buf, m-&gt;count should become zero - we have no valid
contents reachable via m-&gt;buf.

Reported-by: Charley (Hao Chuan) Chu &lt;charley.chu@broadcom.com&gt;
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>seq_file: introduce seq_setwidth() and seq_pad()</title>
<updated>2013-11-15T00:32:20Z</updated>
<author>
<name>Tetsuo Handa</name>
<email>penguin-kernel@I-love.SAKURA.ne.jp</email>
</author>
<published>2013-11-14T22:31:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=839cc2a94cc3665bafe32203c2f095f4dd470a80'/>
<id>urn:sha1:839cc2a94cc3665bafe32203c2f095f4dd470a80</id>
<content type='text'>
There are several users who want to know bytes written by seq_*() for
alignment purpose.  Currently they are using %n format for knowing it
because seq_*() returns 0 on success.

This patch introduces seq_setwidth() and seq_pad() for allowing them to
align without using %n format.

Signed-off-by: Tetsuo Handa &lt;penguin-kernel@I-love.SAKURA.ne.jp&gt;
Signed-off-by: Kees Cook &lt;keescook@chromium.org&gt;
Cc: Joe Perches &lt;joe@perches.com&gt;
Cc: David Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>seq_file: always update file-&gt;f_pos in seq_lseek()</title>
<updated>2013-10-25T14:46:40Z</updated>
<author>
<name>Gu Zheng</name>
<email>guz.fnst@cn.fujitsu.com</email>
</author>
<published>2013-10-25T10:15:06Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=05e16745c0c471bba313961b605b6da3b21a853d'/>
<id>urn:sha1:05e16745c0c471bba313961b605b6da3b21a853d</id>
<content type='text'>
This issue was first pointed out by Jiaxing Wang several months ago, but no
further comments:
https://lkml.org/lkml/2013/6/29/41

As we know pread() does not change f_pos, so after pread(), file-&gt;f_pos
and m-&gt;read_pos become different. And seq_lseek() does not update file-&gt;f_pos
if offset equals to m-&gt;read_pos, so after pread() and seq_lseek()(lseek to
m-&gt;read_pos), then a subsequent read may read from a wrong position, the
following program produces the problem:

    char str1[32] = { 0 };
    char str2[32] = { 0 };
    int poffset = 10;
    int count = 20;

    /*open any seq file*/
    int fd = open("/proc/modules", O_RDONLY);

    pread(fd, str1, count, poffset);
    printf("pread:%s\n", str1);

    /*seek to where m-&gt;read_pos is*/
    lseek(fd, poffset+count, SEEK_SET);

    /*supposed to read from poffset+count, but this read from position 0*/
    read(fd, str2, count);
    printf("read:%s\n", str2);

out put:
pread:
 ck_netbios_ns 12665
read:
 nf_conntrack_netbios

/proc/modules:
nf_conntrack_netbios_ns 12665 0 - Live 0xffffffffa038b000
nf_conntrack_broadcast 12589 1 nf_conntrack_netbios_ns, Live 0xffffffffa0386000

So we always update file-&gt;f_pos to offset in seq_lseek() to fix this issue.

Signed-off-by: Jiaxing Wang &lt;hello.wjx@gmail.com&gt;
Signed-off-by: Gu Zheng &lt;guz.fnst@cn.fujitsu.com&gt;
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>seq_file: add seq_list_*_percpu helpers</title>
<updated>2013-07-08T09:36:41Z</updated>
<author>
<name>Jeff Layton</name>
<email>jlayton@redhat.com</email>
</author>
<published>2013-06-21T12:58:21Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=0bc77381c1b1600e659eb7322c39d1753615722d'/>
<id>urn:sha1:0bc77381c1b1600e659eb7322c39d1753615722d</id>
<content type='text'>
When we convert the file_lock_list to a set of percpu lists, we'll need
a way to iterate over them in order to output /proc/locks info. Add
some seq_list_*_percpu helpers to handle that.

Signed-off-by: Jeff Layton &lt;jlayton@redhat.com&gt;
Acked-by: J. Bruce Fields &lt;bfields@fieldses.org&gt;
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>new helper: single_open_size()</title>
<updated>2013-04-09T18:13:29Z</updated>
<author>
<name>Al Viro</name>
<email>viro@zeniv.linux.org.uk</email>
</author>
<published>2013-03-31T17:43:23Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=2043f495c7c1a06f7748b5bcd17656d93c95e1a6'/>
<id>urn:sha1:2043f495c7c1a06f7748b5bcd17656d93c95e1a6</id>
<content type='text'>
Same as single_open(), but preallocates the buffer of given size.
Doesn't make any sense for sizes up to PAGE_SIZE and doesn't make
sense if output of show() exceeds PAGE_SIZE only rarely - seq_read()
will take care of growing the buffer and redoing show().  If you
_know_ that it will be large, it might make more sense to look into
saner iterator, rather than go with single-shot one.  If that's
impossible, single_open_size() might be for you.

Again, don't use that without a good reason; occasionally that's really
the best way to go, but very often there are better solutions.

Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs</title>
<updated>2013-03-03T21:23:03Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2013-03-03T21:23:02Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=56a79b7b021bf1b08334e63c2c14b280e2dbf47a'/>
<id>urn:sha1:56a79b7b021bf1b08334e63c2c14b280e2dbf47a</id>
<content type='text'>
Pull  more VFS bits from Al Viro:
 "Unfortunately, it looks like xattr series will have to wait until the
  next cycle ;-/

  This pile contains 9p cleanups and fixes (races in v9fs_fid_add()
  etc), fixup for nommu breakage in shmem.c, several cleanups and a bit
  more file_inode() work"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  constify path_get/path_put and fs_struct.c stuff
  fix nommu breakage in shmem.c
  cache the value of file_inode() in struct file
  9p: if v9fs_fid_lookup() gets to asking server, it'd better have hashed dentry
  9p: make sure -&gt;lookup() adds fid to the right dentry
  9p: untangle -&gt;lookup() a bit
  9p: double iput() in -&gt;lookup() if d_materialise_unique() fails
  9p: v9fs_fid_add() can't fail now
  v9fs: get rid of v9fs_dentry
  9p: turn fid-&gt;dlist into hlist
  9p: don't bother with private lock in -&gt;d_fsdata; dentry-&gt;d_lock will do just fine
  more file_inode() open-coded instances
  selinux: opened file can't have NULL or negative -&gt;f_path.dentry

(In the meantime, the hlist traversal macros have changed, so this
required a semantic conflict fixup for the newly hlistified fid-&gt;dlist)
</content>
</entry>
<entry>
<title>fs/seq_file.c:seq_lseek(): fix switch statement indenting</title>
<updated>2013-02-28T03:10:12Z</updated>
<author>
<name>Andrew Morton</name>
<email>akpm@linux-foundation.org</email>
</author>
<published>2013-02-28T01:03:22Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=5e62adef9e1d3e8e26dfd6c95be484b955ad2927'/>
<id>urn:sha1:5e62adef9e1d3e8e26dfd6c95be484b955ad2927</id>
<content type='text'>
[akpm@linux-foundation.org: checkpatch fixes]
Cc: Cyrill Gorcunov &lt;gorcunov@openvz.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>
</entry>
</feed>
