From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0ADECDB483 for ; Tue, 17 Oct 2023 12:58:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343700AbjJQM6N (ORCPT ); Tue, 17 Oct 2023 08:58:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234939AbjJQM6K (ORCPT ); Tue, 17 Oct 2023 08:58:10 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 677EEF1; Tue, 17 Oct 2023 05:58:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697547488; x=1729083488; h=to:cc:subject:references:date:mime-version: content-transfer-encoding:from:message-id:in-reply-to; bh=I32QFltBg3yPBXTGLQ6KOLaePjTdxzeZg3SlmfoCBW0=; b=PXMSmTDyrJZGO8k6mHU6vGsSzqTGt2R3yzEbpQqNETcXIZXcp5lgAw4I melWZGO1fXinHIATBkRsx4SB+jznNoGWRtA6yxM3wqOTXLmnj3xL1DugZ VtuX6whPktwXURUZb6EUKvwaXVRfd1a+0zVxsdDYnYan21MIit/geRpp4 x6EXuwozrag0ge8CE3trRMjKzLHrmZZbQDOG0r/SgtVgGVXUWq3XA6ljP 2JQ03QMNzo4MYC3nV7ZqEUEmfOF1WxPE2R1DfNvMkT4pELuB/UIWQ6BDZ vX/XshBDYn9p7x1j2jY3NbTJQdbgrhdKefBHe6TcCpiCcA1j23eDZTtUn A==; X-IronPort-AV: E=McAfee;i="6600,9927,10866"; a="388632763" X-IronPort-AV: E=Sophos;i="6.03,232,1694761200"; d="scan'208";a="388632763" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2023 05:58:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10866"; a="749677569" X-IronPort-AV: E=Sophos;i="6.03,232,1694761200"; d="scan'208";a="749677569" Received: from hhuan26-mobl.amr.corp.intel.com ([10.92.17.92]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-SHA; 17 Oct 2023 05:58:04 -0700 Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes To: "Christopherson,, Sean" , "Huang, Kai" Cc: "Zhang, Bo" , "linux-sgx@vger.kernel.org" , "cgroups@vger.kernel.org" , "yangjie@microsoft.com" , "dave.hansen@linux.intel.com" , "Li, Zhiquan1" , "linux-kernel@vger.kernel.org" , "mingo@redhat.com" , "tglx@linutronix.de" , "tj@kernel.org" , "anakrish@microsoft.com" , "jarkko@kernel.org" , "hpa@zytor.com" , "mikko.ylinen@linux.intel.com" , "Mehta, Sohil" , "bp@alien8.de" , "x86@kernel.org" , "kristen@linux.intel.com" Subject: Re: [PATCH v5 12/18] x86/sgx: Add EPC OOM path to forcefully reclaim EPC References: <20230923030657.16148-1-haitao.huang@linux.intel.com> <20230923030657.16148-13-haitao.huang@linux.intel.com> <1b265d0c9dfe17de2782962ed26a99cc9d330138.camel@intel.com> <06142144151da06772a9f0cc195a3c8ffcbc07b7.camel@intel.com> <1f7a740f3acff8a04ec95be39864fb3e32d2d96c.camel@intel.com> <631f34613bcc8b5aa41cf519fa9d76bcd57a7650.camel@intel.com> <35a7fde056037a40b3b4b170e2ecd45bf8c4ba9f.camel@intel.com> <915907d56861ef4aa7f9f68e0eb8d136a60bee39.camel@intel.com> Date: Tue, 17 Oct 2023 07:58:02 -0500 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: "Haitao Huang" Organization: Intel Message-ID: In-Reply-To: <915907d56861ef4aa7f9f68e0eb8d136a60bee39.camel@intel.com> User-Agent: Opera Mail/1.0 (Win32) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 16 Oct 2023 20:34:57 -0500, Huang, Kai wrote: > On Mon, 2023-10-16 at 19:10 -0500, Haitao Huang wrote: >> On Mon, 16 Oct 2023 16:09:52 -0500, Huang, Kai >> wrote: >> [...] >> >> > still need to fix the bug mentioned above here. >> > >> > I really think you should just go this simple way: >> > >> > When you want to take EPC back from VM, kill the VM. >> > >> >> My only concern is that this is a compromise due to current limitation >> (no >> other sane way to take EPC from VMs). If we define this behavior and it >> becomes a contract to user space, then we can't change in future. > > Why do we need to "define such behaviour"? > > This isn't some kinda of kernel/userspace ABI IMHO, but only kernel > internal > implementation. Here VM is similar to normal host enclaves. You limit > the > resource, some host enclaves could be killed. Similarly, VM could also > be > killed too. > > And supporting VMM EPC oversubscription doesn't mean VM won't be > killed. The VM > can still be a target to kill after VM's all EPC pages have been swapped > out. > >> >> On the other hand, my understanding the reason you want this behavior is >> to enforce EPC limit at runtime. > > No I just thought this is a bug/issue needs to be fixed. If anyone > believes > this is not a bug/issue then it's a separate discussion. > AFAIK, before we introducing max_write() callback in this series, no misc controller would possibly enforce the limit when misc.max is reduced. e.g. I don't think CVMs be killed when ASID limit is reduced and the cgroup was full before limit is reduced. I think EPC pages to VMs could have the same behavior, once they are given to a guest, never taken back by the host. For enclaves on host side, pages are reclaimable, that allows us to enforce in a similar way to memcg. Thanks Haitao