Received: by 2002:a05:7208:3188:b0:7e:5202:c8b4 with SMTP id r8csp968917rbd; Fri, 23 Feb 2024 09:00:58 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVix4LCAALhp/4mSGN44jyuAgK2/ejWw7p6mI30kZ372JGy/xgQ5nDHshzEbDvfhlOrYlkFf5w83J6T2AUhItu1FGm13WKENiokQ225dw== X-Google-Smtp-Source: AGHT+IHvqJjiM0YjFaN1sJDwSBqXlZq0HYnGqftPpW2aK0HbE5tD168flHBc5pkNquTH6phg6r+W X-Received: by 2002:a17:902:e80d:b0:1dc:75ea:8561 with SMTP id u13-20020a170902e80d00b001dc75ea8561mr487087plg.17.1708707657398; Fri, 23 Feb 2024 09:00:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708707657; cv=pass; d=google.com; s=arc-20160816; b=lahiLSxcLxNxQs/1l7BNqb7iSb6ldNcSHvG9J2VA7r+9SjQhk96IzjfBArJ6sDhWpp wH8K7vCmjOzQQyUpyfkaS7SJtiSH/TWH76djkoHweuj7fOLQaM4n0b+q/oby91j+VvKK qcZehfeyYa3kdkiJK0YeecF4jBe1ZEPhIE0UAQLsgdZjrGnrsL5TO/0q3fSlbtPjnDGT rBFZbUmyiLTu42EZqZR0MB0RQuc2DHrUJPew0DjES03gT30zO8OV8fN11vXKNLAvqVzP k7cQBKA/dwa6wAGWPgI8MwZXTmCe/31OXGZ+pjzekvBRhJSXwkGZB9IcC+8MNYdCmePe RQzw== 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=NQlrzMfrQX2MSXntTwV6o7nUM1iy/iCSuEEmEIIG20A=; fh=7UzHNuuZ8xqWv6S7FduSAlGb/mUlJ87S+85VziWTXqU=; b=zWuEQtpJkuBkTmNdpi2AofTVxqje0ZPpkeR39eENr/qr7klZ0nfKQn3UxBQerU0Eth VZ0owev7yw55nyTLS9A2vEousVv/rbcSdLMRw0elgR8aLm2bAC58kB7iY5+AsGqAb21e kP0KqdzFHsu+F1g/Ov4TZ4OLm/Dw6J+bSF5tb+cD1Ge5haTiYf3xvIeKeZRN5EF7NgjM OyAGLtjuXYFXv0xkpyTe94jMWDTfkPveOrHBraIVeTCpIzH3elk7nE3CKVvbYkr63RD/ KstfevyRi/4aBDMx8PCQTSxq6lpAnyLLIzDzpOrn65NuJ29LI3AcNThN6KvtXttb8Vfx pNNw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZmQUb5Pw; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-78771-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78771-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 ma5-20020a170903094500b001dc0cc1dd92si8368140plb.636.2024.02.23.09.00.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 09:00:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78771-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=ZmQUb5Pw; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-78771-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78771-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 07A3C2845E0 for ; Fri, 23 Feb 2024 17:00:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C086B12C549; Fri, 23 Feb 2024 17:00:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ZmQUb5Pw" 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 3EDBA128833; Fri, 23 Feb 2024 17:00:37 +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=1708707639; cv=none; b=nN4KBQXZhYAPsVfz6Mw9160op2BeLpR3bBXyI0nKv5rCgGXgnvYznzfn9dWg6fUXAkH9YiXkb1rX0oqSp0npaI/NpCVuUA/tgJTnx0Cg8aOyTKgReSoBHTRjKf9Hl8i3YjG0vrODIiCtWHwjc6jFXQLyWBRG+yBDFNJ/iBxAZY8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708707639; c=relaxed/simple; bh=LGoVk6is+8EOUaT6DBqIftn7bdpMxDIZS3roVQ+bxRM=; h=Content-Type:To:Cc:Subject:References:Date:MIME-Version:From: Message-ID:In-Reply-To; b=YyurgBvQkGxPGGIUvzK8+1Z0oxn2Pv0P52rzZZ3ew8WMLl+USI2dAr5R1MeCh79/C+gZ7jkHr+WKCeeSTMTecj+1K490v381D1n/Rh2baqn7eQEaWxR6KIN9j/Bn3C+P63E3+ppMVKgNTELyJDKgSQxuyvzFcADWvBkgFNWKIls= 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=ZmQUb5Pw; 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=1708707638; x=1740243638; h=to:cc:subject:references:date:mime-version: content-transfer-encoding:from:message-id:in-reply-to; bh=LGoVk6is+8EOUaT6DBqIftn7bdpMxDIZS3roVQ+bxRM=; b=ZmQUb5PwEeopoFrMmRGEm3Ri/fixtzZQws1fDciolX88NSDg5R/33I8q O8d+/ZFuhIMi7C3iM3UZOcuHxuNcRxe16avSuWGcT0gurQewDIdYQs8sU D+x1a6UWNjcC/fBhT24GXvuK0lecsl5wMlLHYpbHHgGLWsHIx1t5vFekC emrTA4IUorIoAOTPrNKJO5//PO8MAa3MPNOLoV1AD0eQyUJcVeV0J1YQl eHut2GZhTJ5WPdecoWtUhSEx8EA+LcxGqw071Eq3dreSTKUbmlQZNvq1V LMklk9++fsLD20lJSY6fEaPlZqK+zpUTy+naZivJOEajIkziRicowEhAO w==; X-IronPort-AV: E=McAfee;i="6600,9927,10993"; a="2906473" X-IronPort-AV: E=Sophos;i="6.06,180,1705392000"; d="scan'208";a="2906473" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Feb 2024 09:00:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,180,1705392000"; d="scan'208";a="5902920" Received: from hhuan26-mobl.amr.corp.intel.com ([10.92.17.168]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-SHA; 23 Feb 2024 09:00:35 -0800 Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes To: "Mehta, Sohil" , "mingo@redhat.com" , "jarkko@kernel.org" , "x86@kernel.org" , "dave.hansen@linux.intel.com" , "cgroups@vger.kernel.org" , "hpa@zytor.com" , "tim.c.chen@linux.intel.com" , "linux-sgx@vger.kernel.org" , "mkoutny@suse.com" , "tglx@linutronix.de" , "tj@kernel.org" , "linux-kernel@vger.kernel.org" , "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 v9 10/15] x86/sgx: Add EPC reclamation in cgroup try_charge() References: <20240205210638.157741-1-haitao.huang@linux.intel.com> <20240205210638.157741-11-haitao.huang@linux.intel.com> <4db8493b-35a2-474f-997c-5e6ac1b8bd11@intel.com> Date: Fri, 23 Feb 2024 11:00:32 -0600 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: User-Agent: Opera Mail/1.0 (Win32) On Fri, 23 Feb 2024 04:18:18 -0600, Huang, Kai wrote: >> > >> Right. When code reaches to here, we already passed reclaim per cgroup. > > Yes if try_charge() failed we must do pre-cgroup reclaim. > >> The cgroup may not at or reach limit but system has run out of physical >> EPC. >> > > But after try_charge() we can still choose to reclaim from the current > group, > but not necessarily have to be global, right? I am not sure whether I am > missing something, but could you elaborate why we should choose to > reclaim from > the global? > Once try_charge is done and returns zero that means the cgroup usage is charged and it's not over usage limit. So you really can't reclaim from that cgroup if allocation failed. The only thing you can do is to reclaim globally. This could happen when the sum of limits of all cgroups is greater than the physical EPC, i.e., user is overcommitting. Thanks Haitao