Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1728898lqa; Mon, 29 Apr 2024 18:31:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX461MlDPMa98BV764SsqV+Ctob7CJwO05wp6pnWhIV8VFyCb5SlQqwTmlBe0hnTa7RvJLJvXPi/NS5bXlvz5ZuPM/jxQnCaEwrOnC86w== X-Google-Smtp-Source: AGHT+IELhj3WVPmsvH1/vqGdGKdLtucQxXkTfQhcB4OuBnuCsLgoP5xZe4iXKsAOmPpEvuYK1U+0 X-Received: by 2002:a17:90a:4283:b0:2b2:728a:f517 with SMTP id p3-20020a17090a428300b002b2728af517mr1072009pjg.48.1714440696316; Mon, 29 Apr 2024 18:31:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714440696; cv=pass; d=google.com; s=arc-20160816; b=WV+bZTRvQMLbZJ3zdCRdRLWyUCREwLxEVvKO0ZYQ2eEymDNOYo4FQgdxmIn9l/tZ6j T/rwGysV5NtaJj7N/AKYIUjVl5c0Qug/+h9UZHVjlw62+sP8VbsSVZTxnMq0CAEiRT3a GD1VZ82CnVHzI5WgUjBF1X7bdWHkZrwtz/qHepQ8O4ehotMhl+JMnfWeokHHKX5YVqZE G14ODZhfgo2xoDDvvslbW60gCQrcOLMYLkU5BixCH/ibWwLoNDj0OsO7V159AfWMfDSt jMDerCWXXvTga5izAJTZX6IlorkdO1SSyll/IxhcClh42Xclbg4lkSpAoXqpxOzxKCcL 7Mrw== 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=z7kQEajDgtfaT8ezG5ElbpiHisTKEA4Kb1zshDlwp50=; fh=c7DqcBeHQipkJPapvB1JyMl2o5pSykTZfPfI9Aaj+Z8=; b=xpUqfYO2nO46Dbup/F8iaTZLP2UFAZkPpoX0NKX54Sh4WTyWNkwWvFKi+xKrZ96GZ1 y4e7iJOKoIjUOZQ3cIkBQu434KPVsOZ89Y/pnTpcFz7+vzSypYVMKJ+pMfJQAlE6Q0AL RwsQNPrcoYz0owrXPO6mzR4I2hPFsIFrBwgGE5dtys6uBi0TB29bYsoy60fEq6fah7NW ZqZJOyx3UAkQDtEgcLoGsfZHaJy3nCb9S1OIcUtTEeaGoqPZMhblsdlP2kWKCrGFxjVn 08JTKEdUINNw3Z/Oq5CD0knqGXlzVVROU5Hx7UbSeM0naKW8ErTgpm80QVy2d9NGV8Pg oTmQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HwHpHHcw; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-163230-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163230-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id gp2-20020a17090adf0200b002b2749b073csi679034pjb.145.2024.04.29.18.31.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 18:31:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-163230-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HwHpHHcw; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-163230-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163230-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 C5FD4283229 for ; Tue, 30 Apr 2024 01:31:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1F59528F0; Tue, 30 Apr 2024 01:31:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="HwHpHHcw" 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 B59911113; Tue, 30 Apr 2024 01:31:26 +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=1714440688; cv=none; b=YBWmxEK4+j2Bl/4vrfoPbgMcyZjw3FFWZ6xOGp4NKolB7sxcuJavbM1SvQ0Z6Tmi5tdMB7cLn4hNbkP9ZGorjc0kkvUT4AlQBR0h1LEjr5hNFo/zCd5H7ni8NjLynrOnBsgbNreDFdawPzm1yZDrdtA6IUA/JOg3F+hM7anHhrI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714440688; c=relaxed/simple; bh=qKjIDr0gSCslbsaRgOgQsyWYbY2pEVDT1J9XP6b6+os=; h=Content-Type:To:Cc:Subject:References:Date:MIME-Version:From: Message-ID:In-Reply-To; b=YOV4hKd9odnIScNCD2D4l7gA3HnHS9nEbOtcxdKNfTNeFkJS3O5zfBZU321sYQGH7yzc3P+1QQ3XB2w8c/pgrVsekfDSsRyjvevzHMz+TgVRYShz5GNgju81D76XmE0tyqN+cXaJDa3h6l8vFRO2xuH+5IVKapxYT72lpi3ZN7c= 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=HwHpHHcw; arc=none smtp.client-ip=192.198.163.19 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=1714440687; x=1745976687; h=to:cc:subject:references:date:mime-version: content-transfer-encoding:from:message-id:in-reply-to; bh=qKjIDr0gSCslbsaRgOgQsyWYbY2pEVDT1J9XP6b6+os=; b=HwHpHHcwN1pY4XH3ydmcBhvf2V8U+rjqrP4g/dDb3aDEOWhtWbd1dT4m K5iaotV7UV9ptYo1h85Ohnr5HDI5OSz2CM/XexPQ9/pbGta6v9P8doCN/ CvCvwpp+SSJfjrFaCjVml+me/aV8eyoBM3Uz83xWXZwIq1v3QIM8Qfjg+ xbHf+EsPZyBGKOILl6dp3+LFVTM65k67FoVxM8Ez+w9OieA0kRcw4s3aA K+2w9DbfpHM7QNCQoCO32hbfUrGMTD3j87XMPlrUW0Tfe/h11sySfm8ga pvooxU3o8xmcVdHDtAgENpPMRVZGs1VLdr1EAemJQGd9TNjZdHBp26y1M A==; X-CSE-ConnectionGUID: HqC68nzVR/yAs5WawPyUZA== X-CSE-MsgGUID: t1PFNj7DQjmo8xCsEXzigA== X-IronPort-AV: E=McAfee;i="6600,9927,11059"; a="10002835" X-IronPort-AV: E=Sophos;i="6.07,241,1708416000"; d="scan'208";a="10002835" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2024 18:31:26 -0700 X-CSE-ConnectionGUID: VfkDAxQQSUC4TLRF3ROS6Q== X-CSE-MsgGUID: NTnYZp61RaOTpwE9o4cFJw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,241,1708416000"; d="scan'208";a="26158313" Received: from hhuan26-mobl.amr.corp.intel.com ([10.125.99.222]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/AES256-SHA; 29 Apr 2024 18:31:23 -0700 Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes To: "hpa@zytor.com" , "tim.c.chen@linux.intel.com" , "linux-sgx@vger.kernel.org" , "x86@kernel.org" , "dave.hansen@linux.intel.com" , "jarkko@kernel.org" , "cgroups@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "mkoutny@suse.com" , "tglx@linutronix.de" , "Mehta, Sohil" , "tj@kernel.org" , "mingo@redhat.com" , "bp@alien8.de" , "Huang, Kai" Cc: "mikko.ylinen@linux.intel.com" , "seanjc@google.com" , "anakrish@microsoft.com" , "Zhang, Bo" , "kristen@linux.intel.com" , "yangjie@microsoft.com" , "Li, Zhiquan1" , "chrisyan@microsoft.com" Subject: Re: [PATCH v12 12/14] x86/sgx: Turn on per-cgroup EPC reclamation References: <20240416032011.58578-1-haitao.huang@linux.intel.com> <20240416032011.58578-13-haitao.huang@linux.intel.com> <524cf9b081d86ae61342fdfc370a3639d0010f94.camel@intel.com> <5836260d-600d-4802-9f6a-b0bdb19ddbac@intel.com> Date: Mon, 29 Apr 2024 20:31:21 -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: <5836260d-600d-4802-9f6a-b0bdb19ddbac@intel.com> User-Agent: Opera Mail/1.0 (Win32) On Mon, 29 Apr 2024 17:18:05 -0500, Huang, Kai wrote: > >>>> /* >>>> @@ -42,7 +63,8 @@ static inline struct sgx_epc_lru_list >>>> *sgx_lru_list(struct sgx_epc_page *epc_pag >>>> */ >>>> static inline bool sgx_can_reclaim(void) >>>> { >>>> - return !list_empty(&sgx_global_lru.reclaimable); >>>> + return !sgx_cgroup_lru_empty(misc_cg_root()) || >>>> + !list_empty(&sgx_global_lru.reclaimable); >>>> } >>> >>> Shouldn't this be: >>> >>> if (IS_ENABLED(CONFIG_CGROUP_MISC)) >>> return !sgx_cgroup_lru_empty(misc_cg_root()); >>> else >>> return !list_empty(&sgx_global_lru.reclaimable); >>> ? >>> >>> In this way, it is consistent with the sgx_reclaim_pages_global() >>> below. >>> >> I changed to this way because sgx_cgroup_lru_empty() is now defined in >> both KConfig cases. >> And it seems better to minimize use of the KConfig variables based on >> earlier feedback (some are yours). >> Don't really have strong preference here. So let me know one way of the >> other. >> > > But IMHO your code could be confusing, e.g., it can be interpreted as: > > The EPC pages can be managed by both the cgroup LRUs and the > sgx_global_lru simultaneously at runtime when CONFIG_CGROUP_MISC > is on. > > Which is not true. > > So we should make the code clearly reflect the true behaviour. > Ok, I'll change back. Thanks Haitao