Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp955958pxb; Wed, 6 Apr 2022 05:16:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgNcgC+JdAlZxPFkCjy3osFe9rMhm1vx32XgJ5UhAPuS8B6xc2AH0V6jz6ncZ+EEj4UHBk X-Received: by 2002:a17:902:7247:b0:156:9d3d:756d with SMTP id c7-20020a170902724700b001569d3d756dmr8535311pll.6.1649247362523; Wed, 06 Apr 2022 05:16:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649247362; cv=none; d=google.com; s=arc-20160816; b=BE+nCkGo2Cb+CqzIkeqC9UT+efvkG3TJ7xMh7C+pnemrGYhDSNBj8i3/aedlVETvvM GR09IA0ptEgqv5wiv2g7GcNbJkctnxc+J+G+isBo1ykxn4DGCf14MWesaLtjol49fPUv 1CHJ/9YM1n9NDYsHYIFTbFLopMIy33fKEuT/dq0BUMJWI48sJF5YWBj19SPi6PfHazdJ hL1pdHEWYVRLWkn36XdgWocK9oBImnpg/dBdPJDQC5LeJECHN7q9Vpx2lAiBMjc90/dP uoLotudrt9mGv44EDAYFdZSDLbW0zKC4kRGQQbCYX0lqcSdEL6y5qPi1uIoX5gyx0hib WmaA== 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:subject :from:references:cc:to:content-language:user-agent:mime-version:date :message-id:dkim-signature; bh=iVhsDeRFqJhb995uAghIumbqqwpj4QlhsKXMAioL7gI=; b=ZHFji/ezMg/iUZablPN88hyb8Q9D5vhcuyZ95714I3BRZ5kXbDkwT8LSO78DHvvLK8 BYshWJMWujUUMm098YA9ledJNkRoyx6rKI6su9/FQGHqeo3UTp1TYYSaeuVIMowus/qI bAMPRgsA0Q+xcJaVM2OkOx5vakUwpFCXvplHz/KnldgJf+lK9HKTwIp4PWYZmW57C+m4 vHs477OMHERkW4urE6Mq2IUx1ezAE/hVPYSVZvEhYQgjaXdha9FoRrjUt2v7d4Pg0M05 EIKHxS5JILTGTUZmqhLL/yzY0WqHm/fEPxDf1IBo7CSZ713p/Ia+FQ99j3Hz6CiwETIH Eenw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Gt5QqY71; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id cn3-20020a056a00340300b004fe52f14401si1321484pfb.372.2022.04.06.05.16.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 05:16:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Gt5QqY71; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 61B1951906A; Wed, 6 Apr 2022 03:55:32 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1588226AbiDFAOy (ORCPT + 99 others); Tue, 5 Apr 2022 20:14:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1572956AbiDER1N (ORCPT ); Tue, 5 Apr 2022 13:27:13 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 377A318378; Tue, 5 Apr 2022 10:25:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649179515; x=1680715515; h=message-id:date:mime-version:to:cc:references:from: subject:in-reply-to:content-transfer-encoding; bh=tby6oKK3JVUxlZzYdf5ed1y/wZs9gYYk5yFKCDN1HZg=; b=Gt5QqY71asenE8KEihaKWCkItV1rvRRg1/1D95jskDMRPSd693UBpuA2 6EeVKnqBeJruLKYP3T0+fn4F7HZOdfL0XNI1n2xN0Y/9z9peNXK4vYF+A ccIkAG0aaxyuk2JapMDhbBZ4oh+iuVsasutj3B96F9MSegOj+VvQ7k17K 8JDY2ktQx2WQ1+AakrBZuEi+2epWqfsBK8pAZcy5TjyDV65Oln+yXYg++ elUpY00wjPsmDQMAOgw8p/y68Jr4AgJAmp/2ZDjLpar2Kpq0UsFdKiCpz O/51nVpcOynjECVITQILcrLRC6/R2c+dhz74LE+rlGfcxlVZGp/S0hkKZ w==; X-IronPort-AV: E=McAfee;i="6200,9189,10308"; a="260805737" X-IronPort-AV: E=Sophos;i="5.90,236,1643702400"; d="scan'208";a="260805737" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2022 10:25:14 -0700 X-IronPort-AV: E=Sophos;i="5.90,236,1643702400"; d="scan'208";a="549147373" Received: from nldesimo-desk1.amr.corp.intel.com (HELO [10.212.148.3]) ([10.212.148.3]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2022 10:25:13 -0700 Message-ID: Date: Tue, 5 Apr 2022 10:25:15 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Content-Language: en-US To: Reinette Chatre , Jarkko Sakkinen Cc: dave.hansen@linux.intel.com, tglx@linutronix.de, bp@alien8.de, luto@kernel.org, mingo@redhat.com, linux-sgx@vger.kernel.org, x86@kernel.org, seanjc@google.com, kai.huang@intel.com, cathy.zhang@intel.com, cedric.xing@intel.com, haitao.huang@intel.com, mark.shanahan@intel.com, hpa@zytor.com, linux-kernel@vger.kernel.org References: From: Dave Hansen Subject: Re: [PATCH V3 19/30] x86/sgx: Free up EPC pages directly to support large page ranges In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 4/5/22 10:13, Reinette Chatre wrote: >>> +void sgx_direct_reclaim(void) >>> +{ >>> + if (sgx_should_reclaim(SGX_NR_LOW_PAGES)) >>> + sgx_reclaim_pages(); >>> +} >> Please, instead open code this to both locations - not enough redundancy >> to be worth of new function. Causes only unnecessary cross-referencing >> when maintaining. Otherwise, I agree with the idea. >> > hmmm, that means the heart of the reclaimer (sgx_reclaim_pages()) would be > made available for direct use from everywhere in the driver. I will look into this. I like the change. It's not about reducing code redundancy, it's about *describing* what the code does. Each location could have: /* Enter direct SGX reclaim: */ if (sgx_should_reclaim(SGX_NR_LOW_PAGES)) sgx_reclaim_pages(); Or, it could just be: sgx_direct_reclaim(); Which also provides a logical choke point to add comments, like: /* * sgx_direct_reclaim() should be called in locations where SGX * memory resources might be low and might be needed in order * to make forward progress. */ void sgx_direct_reclaim(void) { ...