Received: by 10.223.185.116 with SMTP id b49csp1144997wrg; Wed, 21 Feb 2018 12:57:04 -0800 (PST) X-Google-Smtp-Source: AH8x224tRKZWuInj/xQacF6sTyv4KrpxbAczkxY7x/pGZpYaFSRA0voSi/2O26pT0v5ctOpkV60/ X-Received: by 2002:a17:902:4d46:: with SMTP id o6-v6mr4200279plh.166.1519246624777; Wed, 21 Feb 2018 12:57:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519246624; cv=none; d=google.com; s=arc-20160816; b=M5qBMThNnvyy5lcsLesA2EDEJD4sPtHYcjIJvlwiIK+901a78zDiK1wi9NovcnG5Iy chcyWufUm4R++v6vHv1OMfT/KSkxHzoBfFOxUAgF6PVouGD5kwrAoLHCZMYJ0UyoOjer ppeJkknxO103oSIRZR6K9C4U7PZjartefiN4gOaS1kEAPeO17a9yzWsPF/1Ov8ZLVuH2 TwwRut0fAi9fspUjCOQV4/gxxKHuWRgeM9Qt1XWXf8xLW9yFy0wtowLcns55D6fqJ1i7 UyFZQ3YCRWQW6oVywyZzhfaUIFQtTmDiGxfhgsLEZr8uNAmDCMYsjidT38jT6WL/8EVm rReQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=xSSMaWjpoHf/WMvI3V/yILaFEaTaufqyaf7/TItT0kY=; b=d4p7W4HJ9B27CI+LgTB+ppmWBVSDpP8I46zj1z0zPsEi6MQ+ctWh772u6g1MHT64aJ XiCzAlDzPAmNa/rp/bXi1zPEQw4Lj6gUTGIE9I76XcS1YhA2b+gQkEFV1qZm0faMHm0G flrGJ0kNuYmTcvSoHIDRZGd8JrCJYIHGQUnOvdOMMx+lyXGBy99JOcctdsBGxRr1fD85 UDfmqtDRdXQ1lyshjT2VYpoT10u2JTc+U587OemzbMQZ46SR9f5jgq+V/2+eeLSL1zB+ jSF4a9/XrCMssCk/pTlmetT7IY1IPBGq/wUoT1oLnyh6mhiXpSgjbwmNVlSUtSdQuHJb XNjg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m4si1886986pgd.450.2018.02.21.12.56.49; Wed, 21 Feb 2018 12:57:04 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751367AbeBUUya (ORCPT + 99 others); Wed, 21 Feb 2018 15:54:30 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:48206 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751119AbeBUUy2 (ORCPT ); Wed, 21 Feb 2018 15:54:28 -0500 Received: from akpm3.svl.corp.google.com (unknown [104.133.9.71]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 4EEE110C7; Wed, 21 Feb 2018 20:54:27 +0000 (UTC) Date: Wed, 21 Feb 2018 12:54:26 -0800 From: Andrew Morton To: Shakeel Butt Cc: Christopher Lameter , Jan Kara , Amir Goldstein , Pekka Enberg , David Rientjes , Joonsoo Kim , Greg Thelen , Johannes Weiner , Michal Hocko , Vladimir Davydov , Mel Gorman , Vlastimil Babka , linux-fsdevel , Linux MM , Cgroups , LKML Subject: Re: [PATCH v2 0/3] Directed kmem charging Message-Id: <20180221125426.464f894d29a0b6e525b2e3be@linux-foundation.org> In-Reply-To: References: <20180221030101.221206-1-shakeelb@google.com> X-Mailer: Sylpheed 3.6.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 21 Feb 2018 09:18:35 -0800 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? > > 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. That would be a lot simpler. Passing function arguments via task_struct is a bit dirty but is sometimes sooo effective. You should've seen how much mess task_struct.journal_info avoided! And reclaim_state. And one always wonders whether we should do a local save/restore before modifying the task_struct field, so it nests. What do others think? Maybe we can rename task_struct.reclaim_state to `struct task_mm_state *task_mm_state", add remote_memcg_to_charge to struct task_mm_state and avoid bloating the task_struct?