Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1405227 > unrolled thread

Re: [PATCH 7/8] pipe: account to kmemcg

Started bykbuild test robot <lkp@intel.com>
First post2016-05-23 12:50 +0200
Last post2016-05-23 14:20 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH 7/8] pipe: account to kmemcg kbuild test robot <lkp@intel.com> - 2016-05-23 12:50 +0200
    Re: [PATCH 7/8] pipe: account to kmemcg Vladimir Davydov <vdavydov@virtuozzo.com> - 2016-05-23 13:00 +0200
      Re: [PATCH 7/8] pipe: account to kmemcg Vladimir Davydov <vdavydov@virtuozzo.com> - 2016-05-23 14:20 +0200

#1405227 — Re: [PATCH 7/8] pipe: account to kmemcg

Fromkbuild test robot <lkp@intel.com>
Date2016-05-23 12:50 +0200
SubjectRe: [PATCH 7/8] pipe: account to kmemcg
Message-ID<rBVAR-4HP-3@gated-at.bofh.it>

[Multipart message — attachments visible in raw view] — view raw

Hi,

[auto build test ERROR on next-20160520]
[cannot apply to tip/x86/core net-next/master v4.6-rc7 v4.6-rc6 v4.6-rc5 v4.6]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Vladimir-Davydov/mm-remove-pointless-struct-in-struct-page-definition/20160523-182939
config: i386-tinyconfig (attached as .config)
compiler: gcc-6 (Debian 6.1.1-1) 6.1.1 20160430
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

Note: the linux-review/Vladimir-Davydov/mm-remove-pointless-struct-in-struct-page-definition/20160523-182939 HEAD 08a247942f52ec5444ba2a0d3c951358640eccf5 builds fine.
      It only hurts bisectibility.

All errors (new ones prefixed by >>):

   fs/built-in.o: In function `anon_pipe_buf_steal':
>> pipe.c:(.text+0x5f8d): undefined reference to `memcg_kmem_uncharge'

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[toc] | [next] | [standalone]


#1405239

FromVladimir Davydov <vdavydov@virtuozzo.com>
Date2016-05-23 13:00 +0200
Message-ID<rBVKy-4Lf-13@gated-at.bofh.it>
In reply to#1405227
On Mon, May 23, 2016 at 06:39:40PM +0800, kbuild test robot wrote:
...
>    fs/built-in.o: In function `anon_pipe_buf_steal':
> >> pipe.c:(.text+0x5f8d): undefined reference to `memcg_kmem_uncharge'

From: Vladimir Davydov <vdavydov@virtuozzo.com>
Subject: [PATCH] pipe-account-to-kmemcg-fix


diff --git a/fs/pipe.c b/fs/pipe.c
index 6345f3543788..b3ad0b33f04e 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -144,8 +144,10 @@ static int anon_pipe_buf_steal(struct pipe_inode_info *pipe,
 	struct page *page = buf->page;
 
 	if (page_count(page) == 1) {
-		memcg_kmem_uncharge(page, 0);
-		__ClearPageKmemcg(page);
+		if (memcg_kmem_enabled()) {
+			memcg_kmem_uncharge(page, 0);
+			__ClearPageKmemcg(page);
+		}
 		__SetPageLocked(page);
 		return 0;
 	}

[toc] | [prev] | [next] | [standalone]


#1405312

FromVladimir Davydov <vdavydov@virtuozzo.com>
Date2016-05-23 14:20 +0200
Message-ID<rBWZY-5FQ-21@gated-at.bofh.it>
In reply to#1405239
On Mon, May 23, 2016 at 01:57:18PM +0300, Vladimir Davydov wrote:
> Subject: [PATCH] pipe-account-to-kmemcg-fix

Darn it, I missed kcalloc in pipe_set_size. Below goes a full version of
this particular patch with both fixes incorporated. Sorry for the noise.
--
From: Vladimir Davydov <vdavydov@virtuozzo.com>
Subject: [PATCH] pipe: account to kmemcg

Pipes can consume a significant amount of system memory, hence they
should be accounted to kmemcg.

This patch marks pipe_inode_info and anonymous pipe buffer page
allocations as __GFP_ACCOUNT so that they would be charged to kmemcg.
Note, since a pipe buffer page can be "stolen" and get reused for other
purposes, including mapping to userspace, we clear PageKmemcg thus
resetting page->_mapcount and uncharge it in anon_pipe_buf_steal, which
is introduced by this patch.

Signed-off-by: Vladimir Davydov <vdavydov@virtuozzo.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>

diff --git a/fs/pipe.c b/fs/pipe.c
index 0d3f5165cb0b..4b32928f5426 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -21,6 +21,7 @@
 #include <linux/audit.h>
 #include <linux/syscalls.h>
 #include <linux/fcntl.h>
+#include <linux/memcontrol.h>
 
 #include <asm/uaccess.h>
 #include <asm/ioctls.h>
@@ -137,6 +138,22 @@ static void anon_pipe_buf_release(struct pipe_inode_info *pipe,
 		put_page(page);
 }
 
+static int anon_pipe_buf_steal(struct pipe_inode_info *pipe,
+			       struct pipe_buffer *buf)
+{
+	struct page *page = buf->page;
+
+	if (page_count(page) == 1) {
+		if (memcg_kmem_enabled()) {
+			memcg_kmem_uncharge(page, 0);
+			__ClearPageKmemcg(page);
+		}
+		__SetPageLocked(page);
+		return 0;
+	}
+	return 1;
+}
+
 /**
  * generic_pipe_buf_steal - attempt to take ownership of a &pipe_buffer
  * @pipe:	the pipe that the buffer belongs to
@@ -219,7 +236,7 @@ static const struct pipe_buf_operations anon_pipe_buf_ops = {
 	.can_merge = 1,
 	.confirm = generic_pipe_buf_confirm,
 	.release = anon_pipe_buf_release,
-	.steal = generic_pipe_buf_steal,
+	.steal = anon_pipe_buf_steal,
 	.get = generic_pipe_buf_get,
 };
 
@@ -227,7 +244,7 @@ static const struct pipe_buf_operations packet_pipe_buf_ops = {
 	.can_merge = 0,
 	.confirm = generic_pipe_buf_confirm,
 	.release = anon_pipe_buf_release,
-	.steal = generic_pipe_buf_steal,
+	.steal = anon_pipe_buf_steal,
 	.get = generic_pipe_buf_get,
 };
 
@@ -405,7 +422,7 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)
 			int copied;
 
 			if (!page) {
-				page = alloc_page(GFP_HIGHUSER);
+				page = alloc_page(GFP_HIGHUSER | __GFP_ACCOUNT);
 				if (unlikely(!page)) {
 					ret = ret ? : -ENOMEM;
 					break;
@@ -611,7 +628,7 @@ struct pipe_inode_info *alloc_pipe_info(void)
 {
 	struct pipe_inode_info *pipe;
 
-	pipe = kzalloc(sizeof(struct pipe_inode_info), GFP_KERNEL);
+	pipe = kzalloc(sizeof(struct pipe_inode_info), GFP_KERNEL_ACCOUNT);
 	if (pipe) {
 		unsigned long pipe_bufs = PIPE_DEF_BUFFERS;
 		struct user_struct *user = get_current_user();
@@ -619,7 +636,9 @@ struct pipe_inode_info *alloc_pipe_info(void)
 		if (!too_many_pipe_buffers_hard(user)) {
 			if (too_many_pipe_buffers_soft(user))
 				pipe_bufs = 1;
-			pipe->bufs = kzalloc(sizeof(struct pipe_buffer) * pipe_bufs, GFP_KERNEL);
+			pipe->bufs = kcalloc(pipe_bufs,
+					     sizeof(struct pipe_buffer),
+					     GFP_KERNEL_ACCOUNT);
 		}
 
 		if (pipe->bufs) {
@@ -1010,7 +1029,8 @@ static long pipe_set_size(struct pipe_inode_info *pipe, unsigned long nr_pages)
 	if (nr_pages < pipe->nrbufs)
 		return -EBUSY;
 
-	bufs = kcalloc(nr_pages, sizeof(*bufs), GFP_KERNEL | __GFP_NOWARN);
+	bufs = kcalloc(nr_pages, sizeof(*bufs),
+		       GFP_KERNEL_ACCOUNT | __GFP_NOWARN);
 	if (unlikely(!bufs))
 		return -ENOMEM;
 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web