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 5C5B9C433EF for ; Tue, 5 Apr 2022 22:12:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233087AbiDEWOJ (ORCPT ); Tue, 5 Apr 2022 18:14:09 -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 Precedence: bulk List-ID: X-Mailing-List: linux-sgx@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) { ...