Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp154093lqh; Mon, 6 May 2024 14:37:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWc+3DQLQQKhCNdQqXGRvONsrCpjTc4IZiZK9we63k8oleO1o4chFGycsMIXlGaJk9MCSGqb6AF2JuOsP2zElnhONZqU4A6TicbAXHciw== X-Google-Smtp-Source: AGHT+IF+lU43QAqGHHln5alpUB/QNuyCjCDjfq1PfaPsU0WT0DeQVUzhWuc0PSdVhDnrUFfvd4NG X-Received: by 2002:a17:907:7246:b0:a59:b342:3ed5 with SMTP id ds6-20020a170907724600b00a59b3423ed5mr4784133ejc.15.1715031423112; Mon, 06 May 2024 14:37:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715031423; cv=pass; d=google.com; s=arc-20160816; b=w1oH8VRbraTDXgEHLZhaOcWHyo3nLNstvDe5Zo41N+ni+x9hy9nPQxzizrHPyS6vYl Qw2YwGINClShnVAg01tpNvyWPL2m3Vt7NuC9gfnB1Qg6bQTWMh8idvQHNOo2jPDNj9Zl 4MyAjkb58RgkUE0iHB8DOkTViXRf+BV/fRrd4RuOrSrBnNicfxlX2Yn9eyyUeQO51/UB EoTSZ4QyWbL6RreJUwKDYXtA6T1uXKFK6cNNhDBCYwwyz2wMUwU5afrYJOGBX4HpQSi0 5CHk8mnDYDX3V3qW6CZDvQoDbO/yanQTv2S4TZt3Z0Fd6MWRhtrMZnpEk4e4Ea94thRN fc5A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:message-id:organization:from :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:references:subject:cc:to :dkim-signature; bh=crP82LL766RURJo/Z7PAsqY/tiyC3U/E1DZ+Nb2mwOY=; fh=ZbN5g22Rz3Glz6OBxASnAsGoXmFQlpn/kT7CqJkS/gk=; b=XOdMZGR8b7Fsudl7WFJeyudvytN0hjaKWdWZfza2xChbWX9l9CzBDka4qCI6Ll212E +RbWbWykdGm6MGtouEfKJ3f8v5yJhV206wdu42pTehg9neK3myc8+YbsRs65P8E5kDU2 HM/b1a8R3QWbgkZpVpFkb6iVNj5mShRwrkyXeZUHJho9Gp5nJ2V3pDLfWJ1KnhkMI3Z6 k511L6qjtAdAU03qTn0dSUOYlDMy4OKrxqWr/5nsgxb8hfJ5JHTWODGhJG0fnld8dabD Ai+Ff5YSpdAw01ndFJKZh6BLQSAAfUJpffcGsWvJNXWt+FQHGBfmQA3Z0akxHwH/fnrR 9ifw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HCAaN023; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-170264-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170264-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id t5-20020a170906a10500b00a593d95f876si5484651ejy.233.2024.05.06.14.37.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 14:37:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170264-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HCAaN023; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-170264-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170264-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 9195E1F23A98 for ; Mon, 6 May 2024 18:01:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7F3F2158A25; Mon, 6 May 2024 18:00:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="HCAaN023" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (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 17E8315749A; Mon, 6 May 2024 18:00:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715018456; cv=none; b=CjPDtZCYLEYUTo0y5v5wVXdR2z8y6+n8S5C8g0WZT5hypZbH3fJvFoU2urkOzxb0YFpkX2aKNeuG8JyJztMYj0XXY8EUzF7hq2TspsRNwiVBzEmKI0mU8wmRJYxUZ9kKDtVbz0Kf9N2RmnNHjWijkGsQGoETgzTkFC+aaSV6abo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715018456; c=relaxed/simple; bh=f/Nm6vtJRqqBh671P2U5uIyh+8sXlTcjJTL36SePe5o=; h=Content-Type:To:Cc:Subject:References:Date:MIME-Version:From: Message-ID:In-Reply-To; b=inz/QdOja4y6sGgR75Z167ovnzERj0gKr2mCT0Canmxpr4hzySGdsX8wIIr1lVLGKibiiDiD5p2e1V8AnMs/hYw0AZA0zksqjn2aMp4R7tdJ8c7TYG5ANg+HFQAmcpy/a0AocrozcGKotOClbxuZfUzpvD9WvSiTlMrsJCfuCwk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=HCAaN023; arc=none smtp.client-ip=192.198.163.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715018455; x=1746554455; h=to:cc:subject:references:date:mime-version: content-transfer-encoding:from:message-id:in-reply-to; bh=f/Nm6vtJRqqBh671P2U5uIyh+8sXlTcjJTL36SePe5o=; b=HCAaN023BetsvyD6zH7S4D+oSVNfUk4tgMvpQJpksnHytwuu+dHDRpN5 7pOKRDeg0zkUVC6xUO58Bd37StUeZCt1RreHrApVlBNAgh+NilB8cKTPc Pfb/Eq+zgBw2DQfRoo3F/QIvXDHTITl7u0QIVsSxHXtbMPiYv5fXUwmk9 rtoOGaNEu9ar7v7AcmQLG99uw4v4Ph2A38oWTSEK4tb5nmJTvLjv8WD4W ojaypF45LmB7AklAefMoXgmqeBRJ+DJlw10tScJ3dpnoLCL/5kUuqy2ow jjsQu4Jh7wJkCBCsAqlkijNjY7tHZF2EXlSr1/xc+9TeAqVBA/IBkP5Rj w==; X-CSE-ConnectionGUID: +jQyBe01Sd+OYnZPOsiD6A== X-CSE-MsgGUID: hBOc87VzR9Ct7w0JLjpnug== X-IronPort-AV: E=McAfee;i="6600,9927,11065"; a="36162882" X-IronPort-AV: E=Sophos;i="6.07,259,1708416000"; d="scan'208";a="36162882" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 May 2024 11:00:53 -0700 X-CSE-ConnectionGUID: xgWPnwH2RBWiuXwZjTJ2WQ== X-CSE-MsgGUID: 3pKBw7FwQkyMaaNdVXJC3A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,259,1708416000"; d="scan'208";a="59417151" Received: from hhuan26-mobl.amr.corp.intel.com ([10.125.210.0]) by smtpauth.intel.com with ESMTP/TLS/AES256-SHA; 06 May 2024 11:00:48 -0700 Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes To: 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, "Huang, Kai" 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 Subject: Re: [PATCH v13 11/14] x86/sgx: Abstract check for global reclaimable pages References: <20240430195108.5676-1-haitao.huang@linux.intel.com> <20240430195108.5676-12-haitao.huang@linux.intel.com> <3eb37a6d-ff52-41b0-8f74-d9d049e6ce05@intel.com> Date: Mon, 06 May 2024 13:00:46 -0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: "Haitao Huang" Organization: Intel Message-ID: In-Reply-To: <3eb37a6d-ff52-41b0-8f74-d9d049e6ce05@intel.com> User-Agent: Opera Mail/1.0 (Win32) Hi Kai Sorry there seems to be some delay in receiving my emails. On Thu, 02 May 2024 18:23:06 -0500, Huang, Kai wrote: > > > On 1/05/2024 7:51 am, Haitao Huang wrote: >> From: Kristen Carlson Accardi >> For the global reclaimer to determine if any page available for >> reclamation at the global level, it currently only checks for emptiness >> of the global LRU. That will be inadequate when pages are tracked in >> multiple LRUs, one per cgroup. For this purpose, create a new helper, >> sgx_can_reclaim_global(), to abstract this check. Currently it only >> checks the global LRU, later will check emptiness of LRUs of all cgroups >> when per-cgroup tracking is turned on. >> Replace all the checks for emptiness of the global LRU, >> list_empty(&sgx_global_lru.reclaimable), with calls to >> sgx_can_reclaim_global(). >> Rename sgx_should_reclaim() to sgx_should_reclaim_global() as it is >> used >> to check if a global reclamation should be performed. >> Co-developed-by: Sean Christopherson >> Signed-off-by: Sean Christopherson >> Signed-off-by: Kristen Carlson Accardi >> Co-developed-by: Haitao Huang >> Signed-off-by: Haitao Huang >> Tested-by: Jarkko Sakkinen >> --- > > Free free to add: > > Reviewed-by: Kai Huang > Thanks > One thing below: > > [...] > >> -static bool sgx_should_reclaim(unsigned long watermark) >> +static bool sgx_should_reclaim_global(unsigned long watermark) >> { >> return atomic_long_read(&sgx_nr_free_pages) < watermark && >> - !list_empty(&sgx_global_lru.reclaimable); >> + sgx_can_reclaim_global(); >> } >> static void sgx_reclaim_pages_global(struct mm_struct *charge_mm) >> @@ -405,7 +413,7 @@ static void sgx_reclaim_pages_global(struct >> mm_struct *charge_mm) >> */ >> void sgx_reclaim_direct(void) >> { >> - if (sgx_should_reclaim(SGX_NR_LOW_PAGES)) >> + if (sgx_should_reclaim_global(SGX_NR_LOW_PAGES)) >> sgx_reclaim_pages_global(current->mm); >> } >> > > Hmm.. Sorry for not pointing out in the previous version. > > Perhaps it makes more sense to do the rename in the patch ... > > x86/sgx: Add basic EPC reclamation flow for cgroup > > ... where we have actually introduced the concept of per-cgroup reclaim, > and we literally have below change in that patch: > > void sgx_reclaim_direct(void) > { > if (sgx_should_reclaim(SGX_NR_LOW_PAGES)) > - sgx_reclaim_pages(); > + sgx_reclaim_pages_global(); > } > > So in that patch, the sgx_should_reclaim() literally just means we > should do gloabl reclaim, but not the per-cgruop reclaim. Thus, perhaps > we just do the renaming here together with the new > sgx_reclaim_pages_global(). > > If there's a new version needed, please move the renaming to that patch? > Will do BR Haitao