Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp670661ybm; Thu, 28 May 2020 12:11:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdjcEUHhqB3tUnCXb2VTXapFhBgGqiVEI3dqciwwJNwvr72Uk/zR7yejzPZNOM7mkBWyoN X-Received: by 2002:aa7:cf17:: with SMTP id a23mr4911267edy.128.1590693077485; Thu, 28 May 2020 12:11:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590693077; cv=none; d=google.com; s=arc-20160816; b=CMYDrEA08ZwYn6Di0f3BIA1UVmkJFpo2jHQ/MUBWyY32qZ9zmKq9/Brt+hpLCMt83A pwnV742+/FJMBAt2Loaf+LnLlmKke+o4R4bAEMA//bli3Mz5jVZ/2sv3FLN81XCdkmOf vsPeRIy27jmeS1BuDJhjNye3l4QRM/8IWvVPhLODFaGpo8LTRTTgU5nVIH7eDcAT5oD/ lUp1j4IQ4yZmCBExHDZTL9lkE/050NPdox9iY350Fk/HMwuH+yEmVbNv0lFkyXL8q0/q vq7Ia2jaDkX3GNkX3PqDfYlaJcwK89QbIVUPak56VvOs7WSIW2RCEk+xpF9Z+o4O/31A BuTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=Nsmqb80IbVPCSj0I7ibFE3OLUFqnI96bbdCt7n15VNE=; b=FsbW++fNIVsmN/1i1Iv4uV4LqYtC3HFiBACDrhtmnNS0zlei2yxZ0ccGV5VGsrxE9x w6ChCHNrIaaahRcufnM/HOS5S4w49sRedLTtKrt+xbN8tSWMsjKH8BWgsHAB2Gsu5iGd XJWyYuyKBkb/uqcX2Za9p8FAQxbzTxvbUcW2dds2Ochpv1Ezom/pJ7CZ7cmd5qVXou4O LKMikLDJtWzmZi/+heTx+UQtnweGEPJxyf+YV+2SCSpog8hq4izBLjjn9r1eU69fOuoh FUOty1bsqR6gjyh9RJKhx4Y1ViGLXdrBZrF/LPMwVRZ3NzYAYIQ7zs3jVO5HAvI9nzms i66A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bu27si4033599edb.169.2020.05.28.12.10.53; Thu, 28 May 2020 12:11:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406205AbgE1THg (ORCPT + 99 others); Thu, 28 May 2020 15:07:36 -0400 Received: from mga18.intel.com ([134.134.136.126]:13720 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406118AbgE1THc (ORCPT ); Thu, 28 May 2020 15:07:32 -0400 IronPort-SDR: EH3QLrK9f0B9TqFHFHT8B9ECEeaJ86fBfYsjH3yZjuRM1g1N3RUVA15eAwHQhbTPWDpvm3k69N M6lQLrWwoKlQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2020 12:07:31 -0700 IronPort-SDR: c2+n63ZwHY+qgdjCq+YtpiNCWzaPGq5MxEgaU8pCPicDaCtnhMkFp8GhaRLiY3YQd847BNFQG8 Ka9t5ZR4ziiA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,445,1583222400"; d="scan'208";a="443080722" Received: from jtitox-mobl.ger.corp.intel.com (HELO localhost) ([10.252.56.171]) by orsmga005.jf.intel.com with ESMTP; 28 May 2020 12:07:22 -0700 Date: Thu, 28 May 2020 22:07:18 +0300 From: Jarkko Sakkinen To: Borislav Petkov Cc: Sean Christopherson , linux-kernel@vger.kernel.org, x86@kernel.org, linux-sgx@vger.kernel.org, akpm@linux-foundation.org, dave.hansen@intel.com, nhorman@redhat.com, npmccallum@redhat.com, haitao.huang@intel.com, andriy.shevchenko@linux.intel.com, tglx@linutronix.de, kai.svahn@intel.com, josh@joshtriplett.org, luto@kernel.org, kai.huang@intel.com, rientjes@google.com, cedric.xing@intel.com, puiterwijk@redhat.com, Jethro Beekman Subject: Re: [PATCH v30 08/20] x86/sgx: Add functions to allocate and free EPC pages Message-ID: <20200528190718.GA2147934@linux.intel.com> References: <20200515004410.723949-1-jarkko.sakkinen@linux.intel.com> <20200515004410.723949-9-jarkko.sakkinen@linux.intel.com> <20200526125207.GE28228@zn.tnic> <20200527042111.GI31696@linux.intel.com> <20200527204638.GG1721@zn.tnic> <20200528012319.GA7577@linux.intel.com> <20200528013617.GD25962@linux.intel.com> <20200528065223.GB188849@linux.intel.com> <20200528171635.GB382@zn.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200528171635.GB382@zn.tnic> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 28, 2020 at 07:16:35PM +0200, Borislav Petkov wrote: > Lemme reply to all mails with one. :-) > > I think Sean almost had it: > > > sgx_alloc_epc_section -> sgx_map_epc_section > > sgx_free_epc_section -> sgx_unmap_epc_section > > Or even > > sgx_setup_epc_section() > sgx_free_epc_section() I like these. Lets lock in. > And except those last two. Those are allocating a page from the EPC > sections so I'd call them: > > sgx_try_alloc_page -> sgx_alloc_epc_page_section > __sgx_try_alloc_page -> __sgx_alloc_epc_page_section > > former doing the loop, latter doing the per-section list games. sgx_alloc_epc_page_section() is a bit nasty and long name to use for grabbing a page. And even the documentation spoke about grabbing before this naming discussion. I think it is a great description what is going on. Everytime I talk about the subject I talk about grabbing. Lets just say that your suggestion, I could not use in a conference talk as a verb when I describe what is going on. That function signature does not fit to my mouth :-) I would talk about grabbing a page. This how I refactored yesterday (is in my GIT tree already): /** * sgx_grab_page() - Grab a free EPC page * @owner: the owner of the EPC page * @reclaim: reclaim pages if necessary * * Iterate through EPC sections and borrow a free EPC page to the caller. When a * page is no longer needed it must be released with sgx_free_page(). If * @reclaim is set to true, directly reclaim pages when we are out of pages. No * mm's can be locked when @reclaim is set to true. * * Finally, wake up ksgxswapd when the number of pages goes below the watermark * before returning back to the caller. * * Return: * an EPC page, * -errno on error */ I also rewrote the kdoc. I do agree that sgx_try_grab_page() should be renamed as __sgx_grab_page(). /Jarkko