Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2759525rwb; Fri, 2 Dec 2022 14:47:28 -0800 (PST) X-Google-Smtp-Source: AA0mqf6ESJO/dXeZEaQulNPnUdIo2WtFiERK60dWKCzauUDEuEcjEUgk7CHcuvHKHSyuh+6KhhL4 X-Received: by 2002:a17:90a:ae16:b0:218:fada:57fd with SMTP id t22-20020a17090aae1600b00218fada57fdmr44024411pjq.12.1670021247743; Fri, 02 Dec 2022 14:47:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670021247; cv=none; d=google.com; s=arc-20160816; b=kwVXeOHpPJBSyih4DCTgeQcKfgCZOMrrAbkBCHd+oAHJraiXXwdHBWHbQwTEVhdSAC p7aYO0GbMdjfaQXL76R2Zrojki+8Uv4dwktPNA2Uyld8Vewjd9pvFqXdPW1oay/zhmGy IhQNtNfS8jqWDUV/i/iCT6vWtwYljEHdx/eCgfqTDsFhVONb5BwFPvi3qK14lIaPyS1P d8psuKlSfyva8KXVn/0eZmMktJE6pH06oaIodgkttV9Noa9dZ4UczdKiCE+3xCLS0eIi jJTk8URgC2JN+tZ0EISOwv7On8nGdWVs/X8Dinw3tsaqEW3jPyJRgnHnMPdwArtzt3Kw h2FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=wejBvIe5qQzHN28j8VEwDfSHnLX2Ru/57YQo8iNGX2o=; b=aqxAlXXiRf/N69WzISDRoQnax1xZip1d3YSjFfYjcgW/IUwhT/Q1wcEzdiTT6XTx/1 cgUiLMnscs8vOy/6hh2IMbSW9afWlGF6t6j+25ZoHftvoeTmNlUTh0j0zSO78pYcsX9O 18VkKXOKmKpkvBiTcLRyAqP6bgbyU+Vwzrj/C4gtXB/hTNkbRdurSFrNbaX94YdZqD+8 nBwJg9hqBzA49WJQ+0sqMRPCGBz6SswMJ4yERJJd9GKqTackzFpBAOlBWU+xZ9d5p06T rLIjKBNDmmbZbCnsH+dNLyAC7wsh1fXOSvQAmUpU6fFl6U87E6fNrU/AEh4X/Yf64Kvb Zhzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=n02GLvs8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l6-20020a17090a4d4600b00200e221e9a0si10881229pjh.149.2022.12.02.14.47.17; Fri, 02 Dec 2022 14:47:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=n02GLvs8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234834AbiLBWNi (ORCPT + 82 others); Fri, 2 Dec 2022 17:13:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234598AbiLBWNX (ORCPT ); Fri, 2 Dec 2022 17:13:23 -0500 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCCE8E8E12; Fri, 2 Dec 2022 14:13:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1670019200; x=1701555200; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=Tc0Asi9Ns/Uw80N6VM1uFJ98uRlF+kEfqeF5kPM3m/M=; b=n02GLvs84dzVV6fFBHSt2M5wLkwPLNR6SSwh9B1xW7w14Ax+WEt+wqAh lmbVakgBmrEty0YacXH7iQzP6DqaFlcLBWOHuELkwaCz7DxsWIPsuKufy kFrV0KJv/JyqdONyTEjUZavVmRbl1b4lKgIrhFT8q6SI3gMpNEHtdjdNW 7Zs6FrxJzsPeREjUO4k545q4C7sulnLExzjp0M8uNDVgm4qh+gYG0o+e/ oEVAXoETJUmR+Q6kqV1hoSE6QVEh4SWIdEKEdH/HTgUnhgcdPHqRQ54N0 e7bzmvoIt+ZiDtqubYshBp255YWu4a4jVqi0C+58oKDsglfX1Kl9uWF4+ g==; X-IronPort-AV: E=McAfee;i="6500,9779,10549"; a="316082121" X-IronPort-AV: E=Sophos;i="5.96,213,1665471600"; d="scan'208";a="316082121" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2022 14:13:20 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10549"; a="638891537" X-IronPort-AV: E=Sophos;i="5.96,213,1665471600"; d="scan'208";a="638891537" Received: from rsnyder-mobl.amr.corp.intel.com (HELO [10.209.68.71]) ([10.209.68.71]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2022 14:13:20 -0800 Message-ID: <1dccd2ec-cad8-b9d2-d66b-aebad21cdb44@intel.com> Date: Fri, 2 Dec 2022 14:13:19 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH v2 05/18] x86/sgx: Track epc pages on reclaimable or unreclaimable lists Content-Language: en-US To: Kristen Carlson Accardi , jarkko@kernel.org, dave.hansen@linux.intel.com, tj@kernel.org, linux-kernel@vger.kernel.org, linux-sgx@vger.kernel.org, cgroups@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" Cc: zhiquan1.li@intel.com, Sean Christopherson References: <20221202183655.3767674-1-kristen@linux.intel.com> <20221202183655.3767674-6-kristen@linux.intel.com> From: Dave Hansen In-Reply-To: <20221202183655.3767674-6-kristen@linux.intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/2/22 10:36, Kristen Carlson Accardi wrote: > Replace functions sgx_mark_page_reclaimable() and > sgx_unmark_page_reclaimable() with sgx_record_epc_page() and > sgx_drop_epc_page(). sgx_record_epc_page() wil add the epc_page > to the correct "reclaimable" or "unreclaimable" list in the > sgx_epc_lru_lists struct. sgx_drop_epc_page() will delete the page > from the LRU list. Tracking pages that are not tracked by > the reclaimer in the sgx_epc_lru_lists "unreclaimable" list allows > an OOM event to cause all the pages in use by an enclave to be freed, > regardless of whether they were reclaimable pages or not. This might be more a comment about Sean's stuff, but could you please start using paragraphs in these changelogs? Also, on the content, I really prefer that patches start off talking in English as much as possible and not just talk about the code. Right now, SGX has a single LRU list. The code is transitioning over to use multiple LRU lists. I'd also prefer that _this_ patch do the: > - sgx_mark_page_reclaimable(entry->epc_page); > + sgx_record_epc_page(entry->epc_page, SGX_EPC_PAGE_RECLAIMER_TRACKED); bits and then *another* patch do the unreclaimable side. This patch could be a straight replacement which is easy to audit. The unreclaimable one needs more thought. I also think this ends up looking a bit weird: > - sgx_epc_push_reclaimable(&sgx_global_lru, page); > + WARN_ON(page->flags & SGX_EPC_PAGE_RECLAIMER_TRACKED); > + page->flags |= flags; > + if (flags & SGX_EPC_PAGE_RECLAIMER_TRACKED) > + sgx_epc_push_reclaimable(&sgx_global_lru, page); > + else > + sgx_epc_push_unreclaimable(&sgx_global_lru, page); > spin_unlock(&sgx_global_lru.lock); > } I think that would be better with a single "push" helper and then let the callers specify the list: if (flags & SGX_EPC_PAGE_RECLAIMER_TRACKED) sgx_lru_push(&sgx_global_lru.reclaimable, page); else sgx_lru_push(&sgx_global_lru.unreclaimable, page);