Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1593807rbb; Mon, 26 Feb 2024 14:57:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWgl4aBG2k6XDlcQmO9WMlW82IrNBk2vcPpGRXi8v0Pa5K7+hcHPdSTPAMUfJIHXTkq97e0DUeTuLfnv6QJD3koe9gWLxdL19+yO6stpg== X-Google-Smtp-Source: AGHT+IE2AUUG6POdjD8tpzBmhKiUen0hkiBdE30kIiZ7gxQy1tto6QN06eIFdZKEIfk+JJQTtuxy X-Received: by 2002:a05:6402:31bb:b0:566:28ae:55d4 with SMTP id dj27-20020a05640231bb00b0056628ae55d4mr811917edb.39.1708988229845; Mon, 26 Feb 2024 14:57:09 -0800 (PST) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id df21-20020a05640230b500b005660742f983si148711edb.330.2024.02.26.14.57.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 14:57:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82419-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=j2mIPVVQ; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-82419-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82419-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 09ACB1F21E80 for ; Mon, 26 Feb 2024 22:46:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D889D135419; Mon, 26 Feb 2024 22:46:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="j2mIPVVQ" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (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 A199A130AEE; Mon, 26 Feb 2024 22:46:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=198.175.65.20 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708987584; cv=fail; b=nVWxOaFWvRfLKyWwc/00QjzugeCMwfchwqWZXccWSGHXTuV+F9OuBDxBw/qxwU7ot+AnYR9AsiPz2xaHD2yRcbJLfUsHw613pR8V7PDC7TrEId7WaXv40V58aCxFT0a810SD0NQLLQWQv7vQSuRXVHR0cccWcbS7wtBRRedz+6E= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708987584; c=relaxed/simple; bh=e7SWonsgQBfKhIabvSD0c0O2W+KAmu5T+eG3Y8kS4YI=; h=Message-ID:Date:Subject:To:CC:References:From:In-Reply-To: Content-Type:MIME-Version; b=HjVaz+JTRMznoDOZ7AyvYuOPMc/S70q+5l7+g9ASeqnI53U36zSyyfTGZ2tI7dk2EZ/yYhmeP4W4q9j2RdrIwwXf2Q9NG4HZ45IVHx6a3VpHe6lEisoI85O+BBncvLH1O1aYJfKdO8Bv5g6qE8K7R7qRX84laNQv/q2wYS0B8jg= ARC-Authentication-Results:i=2; 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=j2mIPVVQ; arc=fail smtp.client-ip=198.175.65.20 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=1708987583; x=1740523583; h=message-id:date:subject:to:cc:references:from: in-reply-to:content-transfer-encoding:mime-version; bh=e7SWonsgQBfKhIabvSD0c0O2W+KAmu5T+eG3Y8kS4YI=; b=j2mIPVVQq9bK7SxjHoerVus/KrNupE28IERlRaPkOZcaUCv2hGb9mkJh Lk9onq16VtnQT/RQTSDAWq1P2sfxSz1cPiHofVqk0TJG+EqOZgT3L/H3E vPbUQQ1tOCje/uJVLvo+5nJ8vSMk4TtTTv64vM3LIaB8rByWW2wOOr9Fh U+QJNofJoXAjKc91lMix0ACEgRo4xVvI3oI2EV3TadQr0dGMwZoy/x2rT C8SojRj4YCZZ3utk0+9gQk1POOufzFmIGjFgpUtAgXlgAlNr2YZuYgaUh h4G//Etf5vHUlPZ8KG24R1FvaJ2dmdbUf7cTi+nb68am+O+viQiDmCk3V Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10996"; a="3174368" X-IronPort-AV: E=Sophos;i="6.06,186,1705392000"; d="scan'208";a="3174368" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 14:46:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,186,1705392000"; d="scan'208";a="11447582" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmviesa004.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 26 Feb 2024 14:46:22 -0800 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 26 Feb 2024 14:46:21 -0800 Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 26 Feb 2024 14:46:20 -0800 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Mon, 26 Feb 2024 14:46:20 -0800 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.101) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 26 Feb 2024 14:46:19 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HzI0ZaH38n+uRRgp3Y84H6jAxR9uepMqa/evvCaZV+A5EH8DhnO3A3OQVB2p6tIrctfb/GB4c1Gbx0gVB1fHd2aEtKSST68HljGManvJLB7RxCTPB3sfpLeeykUl8ZqrRQ27BlHkkPOJIAazG5cQW7GvAg8o8ySdD14znc2Ga3yrM4MIaVEKIEBrigQ9+JWh5wwvFZnCHms5YEQDLit+viEhS0s7y0chSO4W0uyE27nhW9Q/YFk7IfkALNt/D37kcw1FJQTTHX41W8sq3bsvHUkEDU5RPTZrJ0bW8Kdi2miHBDfbYZ8mK+yEs2o1i6qRn/TkGAspePzUjoODKwRIEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=EHNwSCRRI5XeB+bBBZzUH0S/BK2sbWj3IlkKZ1TIf9M=; b=WgQrHASsusPd5Qcy5tWh+ESm/BZfWG/DFNC/JLH9ktnBYZgka508f1QzlSyf81umHQ/V1xpAK+Zsf9sASnnRfB+qQGy5zozTqgZ7wzNiAGIu9rg5NU2zxRZPvuFwqPWQ3kFrPata5WNJY3UiibbXB1cDTElTuhNx2LPyRDDkc+cS+kCVYnbz8Ay4eEyJmP+SKJBD/w0FEz6Js1LA2ZCAYDSGh5+trq8ILUNbdSRHXAZyngYlUVUAf2AXQwW1sAiPtyfJruLMTlb6B9t438qD06OrmM9j6gY4I52bPF9ErY/2/MQYTPS56g8WfNP3GjK9S43GJmaYjCSEe9M+jMljBA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from BL1PR11MB5978.namprd11.prod.outlook.com (2603:10b6:208:385::18) by DM6PR11MB4753.namprd11.prod.outlook.com (2603:10b6:5:2ac::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.25; Mon, 26 Feb 2024 22:46:17 +0000 Received: from BL1PR11MB5978.namprd11.prod.outlook.com ([fe80::ef2c:d500:3461:9b92]) by BL1PR11MB5978.namprd11.prod.outlook.com ([fe80::ef2c:d500:3461:9b92%4]) with mapi id 15.20.7339.024; Mon, 26 Feb 2024 22:46:16 +0000 Message-ID: <022a37e1-7d51-4d64-bb07-91bce848186c@intel.com> Date: Tue, 27 Feb 2024 11:46:02 +1300 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v9 10/15] x86/sgx: Add EPC reclamation in cgroup try_charge() Content-Language: en-US To: Dave Hansen , Haitao Huang , "tj@kernel.org" , "jarkko@kernel.org" , "x86@kernel.org" , "dave.hansen@linux.intel.com" , "cgroups@vger.kernel.org" , "hpa@zytor.com" , "mingo@redhat.com" , "tim.c.chen@linux.intel.com" , "mkoutny@suse.com" , "Mehta, Sohil" , "linux-sgx@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "tglx@linutronix.de" , "bp@alien8.de" 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" References: <20240205210638.157741-1-haitao.huang@linux.intel.com> <20240205210638.157741-11-haitao.huang@linux.intel.com> <4db8493b-35a2-474f-997c-5e6ac1b8bd11@intel.com> <7b53e155-2622-4acb-b7c9-d22e623e4cb3@intel.com> <48faaea8b24f032baa6a858a2909a5b4ace769c6.camel@intel.com> <3f4c6d12-7e0f-44ca-920e-ec219904e0aa@intel.com> From: "Huang, Kai" In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: MW4PR04CA0378.namprd04.prod.outlook.com (2603:10b6:303:81::23) To BL1PR11MB5978.namprd11.prod.outlook.com (2603:10b6:208:385::18) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL1PR11MB5978:EE_|DM6PR11MB4753:EE_ X-MS-Office365-Filtering-Correlation-Id: 9c5f5c7b-9bb4-4296-1d44-08dc371cbe06 X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cF1r3hk5Ei5sAU43O7tsa61u/SmRfhCy3aFbXW8/eoIXHUJNE1epyw7Jz0egbws7S+1iXE/fbhgHNo3ZpODTKBu6OtX9XAVu4O/Mwzz0ovUVBFhh1GRCzzPYAuqTPEEeINNhq8CfwVQTDHrAi1dZ2wKbUWQtj9t2Sxb1hod3OONV02LnvVCRgYdf/wBClNHTKGyi8NzFCCE5z0p8SFCr7EaleD15pPhj+2VKYMNsuEMOt68IZ3OAkH3RdNizp/va+8qk48UzipvJHEbPG4X6WYfb70mp1J3jlRcfMDUEuSSS4nkgEwi3sCrY/4zOAAj9Yl3NozyF+v8pwgRdxmkC48s8aogd/Lg2muBB+44zSCau3GgJ5HnfupnClotIdhR+suOPioM6HQPviH07+Uq8T5AR3vThGtGpaZt9MrR4j9UlIEpdjvVdLm4sTa9VwUERvanNlO1cLcsl5Bpoxr13RZamcn/zVPhS3ufQjDAbHUeMQrxn5ZSFZAy4rYmFy8g2kVXc9HkI6ISU0olCjEndku5cetqA9L5y8d+Ol1/oOLFoa0XzWnuaFdZH7TmFw3JfUV2dPglj+ah1E1kRvHBIvsVVVOyHWCyHjqONGe7G3A33Yv840K3PHJJgYwz6Ycd/vtdTtQteXUdI8zwc1ErXKAP66pGHGq8ZD5H+EXcklP81FL/aJcUuEyjjckuOgW5uSwbD645xWqjf2+gNosu+Jg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BL1PR11MB5978.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(921011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?RHhDWXV1K3R5SEZxWmlTTUJFNkw4azJXUmo5Z09jM0pibmk4eVB4UTJaS0sz?= =?utf-8?B?dElpLzhaVGd2Y1hYaHk1T1BCS0FadkNRTzk4MktpL21HYVJObks5Q3JPZGlt?= =?utf-8?B?SG42UlRGWE9VRmlLYnhTVk9SOWU4RS9QeUswWFBFRS9IaGsvTjFuS09iZ0RX?= =?utf-8?B?Rmk3azE4bCtNQW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UNGxhTGlW?= =?utf-8?B?ZUFmOUdONjQvcm5KVkRjbHQ4LzNHSEZYblhaSTFLMUFXYS9NVkQ3ZStDWG9j?= =?utf-8?B?Zk5NYnhtdDdnL29Bc1NtVlVhaDlNY25rWnlOOGNSbDMwc3FvV01TU294Zzdr?= =?utf-8?Q?4MpUF4rUwzWARLP22oPrYAu6A?= X-MS-Exchange-CrossTenant-Network-Message-Id: 9c5f5c7b-9bb4-4296-1d44-08dc371cbe06 X-MS-Exchange-CrossTenant-AuthSource: BL1PR11MB5978.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Feb 2024 22:46:16.8305 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: AAmOTtUs2f1pYepWz2bW3KpYgJNiVqHI+YW/0IGikzzGDiFK4r6yojh0pz+VUOamABzZxrEBx0FPKVcA7R8blA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB4753 X-OriginatorOrg: intel.com On 27/02/2024 11:38 am, Dave Hansen wrote: > On 2/26/24 14:34, Huang, Kai wrote: >> So I am trying to get the actual downside of doing per-cgroup reclaim or >> the full reason that we choose global reclaim. > > Take the most extreme example: > > while (hit_global_sgx_limit()) > reclaim_from_this(cgroup); > > You eventually end up with all of 'cgroup's pages gone and handed out to > other users on the system who stole them all. Other users might cause > you to go over the global limit. *They* should be paying part of the > cost, not just you and your cgroup. Yeah likely we will need another layer of logic to decide when to do global reclaim. I agree that is downside and is unnecessary for this patchset. Thanks for the comments.