Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp1165982rdb; Fri, 16 Feb 2024 07:16:32 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXg3QQsFfVRMdDdGlqx0kx5hmxvqSf+DMIk6m05UJnSgZDQbGnD6Fm9p20jKJtj27vwK5Xcxoj/JuinfbKt3UwTsxEq29VHw2xt/8phcQ== X-Google-Smtp-Source: AGHT+IEDjhMWGOlK/HgZG1cQ6BuCKWrmY74enc/a7VtEblOmJzMovrvYkcaU4VAchylQfdHS1YBD X-Received: by 2002:a05:6a00:124b:b0:6e0:4717:7a0d with SMTP id u11-20020a056a00124b00b006e047177a0dmr6815752pfi.5.1708096591878; Fri, 16 Feb 2024 07:16:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708096591; cv=pass; d=google.com; s=arc-20160816; b=OjhWh8XVkW5AR8xZkOUMGpt2wfLJB6Zy966sw7A2UF+UQbfj/CNPVkT7Oyxm7iWLwk 44u2eqL2+mp/AXmNGBJc0GFnV6vGrJJqHals95yJ7t9MgsUWvDEzQj7D34j6VOW+7pCu +1YOWZTVRyG6BgRVHDb8/+YQ+C6w7iXWfqEZM15I+tSp3b1+MBeHOOAZvJSIW5jAWPuX d1yzmPANh6Kpd9FqT5gsyzL8EoA0GzuiAzbK4T6b+4uDLFbn8uGILjBXtSTv+0T7ZwKd zhTNxkJgfw2lbuoI4XqYJK/XXtGtv5YrZ0enddkCEDUfvS8E4Yt2UThL5pYGf77DGzcn qbcQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=/OFwAvlLeBiqNkt14SvmEBoRibr9f2zqMA4F02nNrOE=; fh=lnVXoV6VEI6c/bSethkkfKSn8d1jRiYcvDfABYGBqCY=; b=wJfAUSHih75LZJ/ye7qyIYOjQlec8wBR1T9A0mc37Uzs+H82p9D2cb3iWe57eZ2WR+ 3EDxDkrvquS1VGZqWK8ZEVKVmIIKX6L7ueSnBQW/tAtuOeGy0Xl6/ChkKaeJm6WCQWel bnltSYePG3cI9UfBu2NV0anzrT8sKW4ra5qUeSIWfk1ftVLu8PszInobhFDH6oRqXY73 Ck1HrRAr8ujvq82rKaekaS+LeCKnuwJspf4eMCBN0l7N+i5MmrHCWdW4OI6dOJglY3f4 mudwiN3xvbMwyD6sS26OB23efaqBWdzrYaYL5BZWA7dkWrGEPyLz2YqR8yC7vB6g7gjv AMfQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BVFv3OwZ; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-68788-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68788-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id i190-20020a636dc7000000b005d7a78810acsi19719pgc.278.2024.02.16.07.16.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 07:16:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68788-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BVFv3OwZ; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-68788-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68788-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6282A28383F for ; Fri, 16 Feb 2024 15:16:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 94FAA12F5AE; Fri, 16 Feb 2024 15:16:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="BVFv3OwZ" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BFE75768F2; Fri, 16 Feb 2024 15:16:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708096563; cv=none; b=EyfpYflT6PyEElQaodxw1YbPPkQmuyPg7Kg8WInfAN4BwNHYvKtMneOpAhpu43L+71/bRHGWkhVqyWSSJAOSkJ+nGsI1nQ5A++srSGJcGJ9HNxHHxn3qFcAhl3o831XJFvZWYnG6a1bUIFgf+3Alby8E1cDpYvRUXQE778K5nuA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708096563; c=relaxed/simple; bh=Gwn9nO1wjwVJg72Yko0kJdLqPjCBrxFUpXmw05lNXGM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=oZvdwCplA4kKBM7G+GiI3P2/7AJ1BLEUXqBPGC9Y+6WF/DKXWOryr/1EZE9pTinTDXgntYCboktyaEjodVdf3NplSbuoOV5eHnJxJZilWwbQMdwjeOvzRLzHFxVBP/r0X+1cL9tDKwJAJExsfi5K3yfEKGFxN0UaO5jBo7wgbEk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=BVFv3OwZ; arc=none smtp.client-ip=192.198.163.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708096562; x=1739632562; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=Gwn9nO1wjwVJg72Yko0kJdLqPjCBrxFUpXmw05lNXGM=; b=BVFv3OwZN7VbmumGYZmG/OEZC0UEWO8o4Xckd8wRtw/JUjckx5dUBga/ s3mpeoo9wXYcnnZueMxQM6NbUZ4E2MWET0rImokfbrpiqep3zOK7gCnYG dTYKgwYvrTjJ2H8fAvEGz1DIkZxJZ94Zzpq+cz42wm2/2uWEHJwYYYbJW gJzMnB41DM7gYq1OFcI46QJs0VVCbp9lN/43PqsVmkuUNuYEcLGjFJtYD J6cuDa8aKn05ZPlQECRru5Kbp7w6heHR1m54nPAswXryapFpMpKLw1pSQ JbYMguGX3sTgqwsbfPlzB5s/1lYm33fklO8/EnZ7LSP/lsKo6U4KgcNds A==; X-IronPort-AV: E=McAfee;i="6600,9927,10985"; a="2093074" X-IronPort-AV: E=Sophos;i="6.06,164,1705392000"; d="scan'208";a="2093074" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2024 07:16:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,164,1705392000"; d="scan'208";a="4252126" Received: from smidford-mobl.amr.corp.intel.com (HELO [10.209.63.169]) ([10.209.63.169]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2024 07:16:00 -0800 Message-ID: Date: Fri, 16 Feb 2024 07:15:59 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v9 09/15] x86/sgx: Charge mem_cgroup for per-cgroup reclamation Content-Language: en-US To: Haitao Huang , jarkko@kernel.org, dave.hansen@linux.intel.com, tj@kernel.org, mkoutny@suse.com, linux-kernel@vger.kernel.org, linux-sgx@vger.kernel.org, x86@kernel.org, cgroups@vger.kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, sohil.mehta@intel.com, tim.c.chen@linux.intel.com Cc: zhiquan1.li@intel.com, kristen@linux.intel.com, seanjc@google.com, zhanb@microsoft.com, anakrish@microsoft.com, mikko.ylinen@linux.intel.com, yangjie@microsoft.com, chrisyan@microsoft.com References: <20240205210638.157741-1-haitao.huang@linux.intel.com> <20240205210638.157741-10-haitao.huang@linux.intel.com> From: Dave Hansen Autocrypt: addr=dave.hansen@intel.com; keydata= xsFNBE6HMP0BEADIMA3XYkQfF3dwHlj58Yjsc4E5y5G67cfbt8dvaUq2fx1lR0K9h1bOI6fC oAiUXvGAOxPDsB/P6UEOISPpLl5IuYsSwAeZGkdQ5g6m1xq7AlDJQZddhr/1DC/nMVa/2BoY 2UnKuZuSBu7lgOE193+7Uks3416N2hTkyKUSNkduyoZ9F5twiBhxPJwPtn/wnch6n5RsoXsb ygOEDxLEsSk/7eyFycjE+btUtAWZtx+HseyaGfqkZK0Z9bT1lsaHecmB203xShwCPT49Blxz VOab8668QpaEOdLGh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Tm+whm +AyNTjaCRt6aSMnA/QHVGSJ8grrTJCoACVNhnXg/R0g90g8iV8Q+IBZyDkG0tBThaDdw1B2l asInUTeb9EiVfL/Zjdg5VWiF9LL7iS+9hTeVdR09vThQ/DhVbCNxVk+DtyBHsjOKifrVsYep WpRGBIAu3bK8eXtyvrw1igWTNs2wazJ71+0z2jMzbclKAyRHKU9JdN6Hkkgr2nPb561yjcB8 sIq1pFXKyO+nKy6SZYxOvHxCcjk2fkw6UmPU6/j/nQlj2lfOAgNVKuDLothIxzi8pndB8Jju KktE5HJqUUMXePkAYIxEQ0mMc8Po7tuXdejgPMwgP7x65xtfEqI0RuzbUioFltsp1jUaRwQZ MTsCeQDdjpgHsj+P2ZDeEKCbma4m6Ez/YWs4+zDm1X8uZDkZcfQlD9NldbKDJEXLIjYWo1PH hYepSffIWPyvBMBTW2W5FRjJ4vLRrJSUoEfJuPQ3vW9Y73foyo/qFoURHO48AinGPZ7PC7TF vUaNOTjKedrqHkaOcqB185ahG2had0xnFsDPlx5y In-Reply-To: <20240205210638.157741-10-haitao.huang@linux.intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2/5/24 13:06, Haitao Huang wrote: > @@ -414,7 +416,7 @@ static void sgx_reclaim_pages_global(void) > void sgx_reclaim_direct(void) > { > if (sgx_should_reclaim(SGX_NR_LOW_PAGES)) > - sgx_reclaim_pages_global(); > + sgx_reclaim_pages_global(false); > } > > static int ksgxd(void *p) > @@ -437,7 +439,7 @@ static int ksgxd(void *p) > sgx_should_reclaim(SGX_NR_HIGH_PAGES)); > > if (sgx_should_reclaim(SGX_NR_HIGH_PAGES)) > - sgx_reclaim_pages_global(); > + sgx_reclaim_pages_global(true); > > cond_resched(); > } First, I'm never a fan of random true/false or 0/1 arguments to functions like this. You end up having to go look at the called function to make any sense of it. You can either do an enum, or some construct like this: if (sgx_should_reclaim(SGX_NR_HIGH_PAGES)) { bool indirect = true; sgx_reclaim_pages_global(indirect); } Yeah, it takes a few more lines but it saves you having to comment the thing. Does this 'indirect' change any behavior other than whether it does a search for an mm to find a place to charge the backing storage? Instead of passing a flag around, why not just pass the mm? This refactoring out of 'indirect' or passing the mm around really wants to be in its own patch anyway.