Received: by 10.223.185.116 with SMTP id b49csp1101377wrg; Wed, 21 Feb 2018 12:07:45 -0800 (PST) X-Google-Smtp-Source: AH8x225DRs7ZJSh3/mcHkB/l76/vVVDmwouZoF4KdH7BDzQa1DXWHeIPw5qZjXdrSNf4gdsaM2KA X-Received: by 2002:a17:902:a607:: with SMTP id u7-v6mr4094635plq.367.1519243665102; Wed, 21 Feb 2018 12:07:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519243665; cv=none; d=google.com; s=arc-20160816; b=JQWtIihfs2gMDVl7WjB+h8HgRPFeifjtjGogE2EDhWr9KNs5Ai7ANzo0Ot70hmRk/t 5N0zUCPJy8vHKHT3/5MUXh8lcsR7eCOH3ktx1UpF5s5C7tJmS0/XDGMVLMRtdCxuYeGR WByxpcKC+FHDyy0y2DFu8FzOKdiHTskoCdUuk6LjkzAHdjC3JkUJjqpghOk93/wHtNQC Cs8hv/RB4+BVnwYafcBj3/55e7q55YqiJ7sS1RiHqPrYv17/fze97k4Jrg53XezjE87v DvTfeYb72f6pcecel88ydCf14x5SIew5PgHd8WzumSapDvjOJRpa6/BmSN8JMnWp+zwS ZLeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=TXepbPMq3Sio6awhkdE9AugIAK9uZQNx2XMHRxsvsnM=; b=xz5YORArBd5h/Ss3bE0QDQr8Lss3gowRiZdVjncA4b8m+7IpGd6gipohWcidKT1dJ7 6crDN3Va0x3Ne0/7I2bcrbR47uMVhC1qlJOLMQRV+o42WFvNpjd7VWmWMJTQU//jk/bc vZ96oYLCGmqG2Nb7Ah/xVtHZiy43maxpwOsW5vxalY2gg54SI+vGW8ljlbE8NNllWjxz wmra6x1FyIyFWfHSaJ17/lmMNKCfLcwn2Awkz8mAN2cCzbhKnAE2u71GragvP9MLQUS8 wZql6FwjGFxLFWX7N+hPrLsJ6cwPNNsY6sqVMiJS9Ft0e1XnUglLALqIDeTMRJHeRTfP 2VVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=v4rdhbQI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u188si1460782pgb.648.2018.02.21.12.07.30; Wed, 21 Feb 2018 12:07:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=v4rdhbQI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751359AbeBUUFQ (ORCPT + 99 others); Wed, 21 Feb 2018 15:05:16 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:42074 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751300AbeBUUFO (ORCPT ); Wed, 21 Feb 2018 15:05:14 -0500 Received: by mail-wr0-f193.google.com with SMTP id k9so7906898wre.9 for ; Wed, 21 Feb 2018 12:05:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=TXepbPMq3Sio6awhkdE9AugIAK9uZQNx2XMHRxsvsnM=; b=v4rdhbQIOm4+5la8Wy32kiEjec7W5ZXWCr7eV717aY7uxSlgecGEyEVc/jJrzVWU+m HlsYZ0nkC2dnMEjR+9ALX1XUO83RXByzgo08JKkalNjSxQZSVLug66XVRX0ibzHwPhqG q+xEomizBqAcT/M6vWGtZzmvihtbN4BqTfzhvGTms8yJpRcE4Gb2hopz3d8BMPIEMrRm t7mM0buuNbSWix927i9guyQaIkELPfS7XCLhBTecftl40+4BJAsbeKLy6bHIefYqh6Ca llwLI0CVLX564543OjFVVdSX+6uuA01GB4rVv9wLRctxXMn+L41ZB8nwd8lGtOGc+gr2 4koA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=TXepbPMq3Sio6awhkdE9AugIAK9uZQNx2XMHRxsvsnM=; b=HExyDPvv5eU+4n0TmxJ/nwUG48upeGddYzETyEkaT8+cvZtpcKHM3Vv8S25q7i0rNz mKYrJb+RwdmT4ceJV4p/RjEyRLXBzi7xaOTizXUxIV1yc4G2p+9jgXT8s1lQG4wiOWts s341K6TU7CUROBfJAEvhXtPTfpxlBw//TKyiu96WphE9PqP+Zt1F3X+RR+g77XEke90w R3jyj6PDZhHbwr00CcbT/nEM31GYSL7php+lpIJ6pI5S1jPwU+hAfekp6mmHX5hNuw6D 0ttbC6u62KK5cR54UIcmaJT0KcC4FOFMwsxkJMrBJ83JucM8WHEWlSaaLx+YKHSN7f9w m2iA== X-Gm-Message-State: APf1xPDf7eMfu1OFTceMv3hzncS4VeeyvHWIim/XRNhs+GTFDVnmoQno ItgR+ALeTU2vhA+OBewDuxYAvoBhVPcEeBLBqUd/KA== X-Received: by 10.28.41.3 with SMTP id p3mr3091725wmp.140.1519243512604; Wed, 21 Feb 2018 12:05:12 -0800 (PST) MIME-Version: 1.0 Received: by 10.28.55.204 with HTTP; Wed, 21 Feb 2018 12:05:11 -0800 (PST) In-Reply-To: References: <20180221030101.221206-1-shakeelb@google.com> From: Shakeel Butt Date: Wed, 21 Feb 2018 12:05:11 -0800 Message-ID: Subject: Re: [PATCH v2 0/3] Directed kmem charging To: Christopher Lameter Cc: Jan Kara , Amir Goldstein , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Greg Thelen , Johannes Weiner , Michal Hocko , Vladimir Davydov , Mel Gorman , Vlastimil Babka , linux-fsdevel , Linux MM , Cgroups , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 21, 2018 at 9:57 AM, Christopher Lameter wrote: > On Wed, 21 Feb 2018, Shakeel Butt wrote: > >> On Wed, Feb 21, 2018 at 8:09 AM, Christopher Lameter wrote: >> > Another way to solve this is to switch the user context right? >> > >> > Isnt it possible to avoid these patches if do the allocation in another >> > task context instead? >> > >> >> Sorry, can you please explain what you mean by 'switch the user >> context'. Is there any example in kernel which does something similar? > > See include/linux/task_work.h. One use case is in mntput_no_expire() in > linux/fs/namespace.c > From what I understand, using task_work will require fanotify/inotify event handler to allocate memory asynchronously. IMHO the code will be much more complex if we go through that route. > Another way is by adding a field 'remote_memcg_to_charge' in > task_struct and set it before the allocation and in memcontrol.c, > first check if current->remote_memcg_to_charge is set otherwise use > the memcg of current. Also if we provide a wrapper to do that for the > user, there will be a lot less plumbing. > > Please let me know if you prefer this approach. > What do you think of the above approach. I think the amount and complexity of code will be much less. >> > Are there really any other use cases beyond fsnotify? >> > >> >> Another use case I have in mind and plan to upstream is to bind a >> filesystem mount with a memcg. So, all the file pages (or anon pages >> for shmem) and kmem (like inodes and dentry) will be charged to that >> memcg. > > The mount logic already uses task_work.h. That may be the approach to > expand there. The task_work approach will require that the job is already running at the time of mount operation. Usually the mount operations are done by either admin or the control task starting the job and is a part of setting up the environment. So, there might not be any process running at the time of mount operation.