Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp769219rwb; Thu, 8 Dec 2022 02:44:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf52dgkmUY2BYCsxE2UMI5i/fu8Xwl1fUTs5Ngg6gK4LgCMac9rKqlPcmi654ON6s9DLwxOi X-Received: by 2002:a17:90b:386:b0:219:7f95:5076 with SMTP id ga6-20020a17090b038600b002197f955076mr32616472pjb.54.1670496293019; Thu, 08 Dec 2022 02:44:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670496293; cv=none; d=google.com; s=arc-20160816; b=dJA1zAJJXVdlAXN7ozgPoNLluzG94xkkdGkhRH8ddeca+plK4u08PpC9Ey2coyGcsx 3PSLNS1brEeXpC30uO4UDUrFhdUr60RFNvHCSzDi7Yx3+lGf1moGYEuR43B3MCXmWaLj bz73+5+lCWY8vZaaXswPnm9vmzXgXQJdg3o811Xcm6sNL+wDBO7iDE7sg0/lc8ihIVqH psj2GnrGZs3AGwgVcE5ODlBfPrS+/b1/XwqZ2gSco4dyIwuDfdTvCTwyK77zvkYk/0sj B1qsfcoE+pmNdr++kqC5+4eh7SRXIoNihiX/+now91JrbAdJuetH6TfHSizJJRT4E8C1 +zuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=jGCBKbPvpGPD+AhT3mWZa5kiZZVQ4zgdZsoctJyz1TI=; b=P4iOfHDIeJcUHWhssXK4CRgpluVLCQ8KC7Or5dmeKqL36rvFMdTZbhEtY9huN0eGK3 KqjXAm4pTV7rw9akcZ7LyMl6rsbYKMdd6YQMvNRJZhM7lxxNTqdfBXKub5+OYmN4xHgd gtDX+pznsqWaxfghvKTLVeSZ4u3TTBxFFPut3qdtfLbGWWRRPBBBEPGqyw8QBb//BgFb klHm6EU761YvtmeWlj0ru+8U+BqzztGWhdLcKsqezqlB8OET7MR4cswbG6T/GQ8JpdjY iBReWelbYmTNGbmN90DRb+jy+NRy7UOvAZ5UFaHiTHzk96wZQUJqWmB2vs5HdKlzyvRt fWug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FCSyXRUa; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 64-20020a630843000000b004770fe91070si22444202pgi.587.2022.12.08.02.44.43; Thu, 08 Dec 2022 02:44:53 -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=@kernel.org header.s=k20201202 header.b=FCSyXRUa; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229793AbiLHJ5E (ORCPT + 72 others); Thu, 8 Dec 2022 04:57:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbiLHJ5D (ORCPT ); Thu, 8 Dec 2022 04:57:03 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C3FA654ED; Thu, 8 Dec 2022 01:57:02 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E613261E61; Thu, 8 Dec 2022 09:57:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EDE15C433C1; Thu, 8 Dec 2022 09:57:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670493421; bh=0YONDyXSVa33MyT3Y1l44dW3jNZREl8JU1hVtA1zMfc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=FCSyXRUaBuN5Gfn5yMzGv4WNYwCtUjmYth2dtuI2WPqWJmXCbUCNNo4MJjxsRQ7ml 25QzxXJWThQe16pB9msMXeV0V57sqf/XAySKr4f75hUXFY2JcCfdIksFAZ/ZPyTy26 6qk6jXvM50+/jZ+dD8dNsPtT0HPYua0aq+PQDwRZz6q6DFvr05138ugmelxchXQVBM iG2Mjy+BK5qKg/aunxPyWAWnPDMNRYj4WmIDc3a/B5trq9ndv5eGo2WT+/23TAmAr8 nqalOGJABkT5Y9hC3StQq0HehSbsEBdrd71JX42YX0hF4I0DK6mFYiNbhKJsxb2Tpc OeVJD4rNFw2Ng== Date: Thu, 8 Dec 2022 09:56:57 +0000 From: Jarkko Sakkinen To: Kristen Carlson Accardi Cc: 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" , zhiquan1.li@intel.com, Sean Christopherson Subject: Re: [PATCH v2 13/18] x86/sgx: Add helper to grab pages from an arbitrary EPC LRU Message-ID: References: <20221202183655.3767674-1-kristen@linux.intel.com> <20221202183655.3767674-14-kristen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221202183655.3767674-14-kristen@linux.intel.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 Fri, Dec 02, 2022 at 10:36:49AM -0800, Kristen Carlson Accardi wrote: > From: Sean Christopherson > > Move the isolation loop into a standalone helper, sgx_isolate_pages(), > in preparation for existence of multiple LRUs. Expose the helper to > other SGX code so that it can be called from the EPC cgroup code, e.g. > to isolate pages from a single cgroup LRU. Exposing the isolation loop > allows the cgroup iteration logic to be wholly encapsulated within the > cgroup code. > > Signed-off-by: Sean Christopherson > Signed-off-by: Kristen Carlson Accardi > Cc: Sean Christopherson > --- > arch/x86/kernel/cpu/sgx/main.c | 68 +++++++++++++++++++++------------- > arch/x86/kernel/cpu/sgx/sgx.h | 2 + > 2 files changed, 44 insertions(+), 26 deletions(-) > > diff --git a/arch/x86/kernel/cpu/sgx/main.c b/arch/x86/kernel/cpu/sgx/main.c > index c947b4ae06f3..a59550fa150b 100644 > --- a/arch/x86/kernel/cpu/sgx/main.c > +++ b/arch/x86/kernel/cpu/sgx/main.c > @@ -280,7 +280,46 @@ static void sgx_reclaimer_write(struct sgx_epc_page *epc_page, > } > > /** > - * sgx_reclaim_pages() - Reclaim EPC pages from the consumers > + * sgx_isolate_epc_pages() - Isolate pages from an LRU for reclaim > + * @lru: LRU from which to reclaim > + * @nr_to_scan: Number of pages to scan for reclaim > + * @dst: Destination list to hold the isolated pages > + */ > +void sgx_isolate_epc_pages(struct sgx_epc_lru_lists *lru, int *nr_to_scan, > + struct list_head *dst) Why not instead return the number of pages scanned, and pass 'int nr_to_scan'? That would just be more idiomatic choice. BR, Jarkko