All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: Borislav Petkov <bp@alien8.de>
Cc: linux-sgx@vger.kernel.org,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] x86/sgx: Add sgx_nr_{all, free}_pages to the debugfs
Date: Wed, 7 Apr 2021 19:09:11 +0300	[thread overview]
Message-ID: <YG3ZJyMB+S5LcUso@kernel.org> (raw)
In-Reply-To: <20210407155636.GG25319@zn.tnic>

On Wed, Apr 07, 2021 at 05:56:36PM +0200, Borislav Petkov wrote:
> On Tue, Apr 06, 2021 at 02:26:53AM +0300, Jarkko Sakkinen wrote:
> > Add two debugs attributes:
> > 
> > * /sys/kernel/debug/x86/sgx_nr_all_pages
> > * /sys/kernel/debug/x86/sgx_nr_free_pages
> 
> Definitely under /sys/kernel/debug/x86/sgx/...
> 				      ^^^^^^
> 
> > These provide useful statistics for testing purposes.
> 
> Testing what exactly?
> 
> Also, if those are EPC pages, why isn't "epc" in the name?

When debugging the SGX code it is useful to quickly check the amount of
EPC pages, and also total amount of EPC available.

I left out "epc" because they are already prefixed with "sgx_".

> > E.g. on a NUC7CJYH2, when no enclaves are running, and EPC set to 32 MB:
> > 
> > $ sudo cat /sys/kernel/debug/x86/sgx_nr_all_pages
> > 5632
> > 
> > $ sudo cat /sys/kernel/debug/x86/sgx_nr_free_pages
> > 5632
> 
> I have no clue what that is useful for. You want to account how many of
> the EPC pages on all nodes are in use? What for?
> 
> Are those globally useful for people? If so, they need to go to sysfs
> along with documentation what they do.
> 
> If not, you can keep this patch in your tree for your own testing.

E.g. when stress testing this might be useful information to scale the
workload for example, or even sample the number of EPC pages. When
otherwise testing this might be useful to catch any leaks. I created
1/2 based on what I saw with these variables.

debugfs was my first shot, but for sure these could be sysfs.

> > Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
> > ---
> > 
> > v2:
> > * Use debugfs_create_ulong():
> >   https://lore.kernel.org/linux-sgx/57c18e08-3e36-b5b3-aaba-9a21b75a1613@intel.com/
> > 
> >  arch/x86/kernel/cpu/sgx/main.c | 13 ++++++++++++-
> >  1 file changed, 12 insertions(+), 1 deletion(-)
> > 
> > diff --git a/arch/x86/kernel/cpu/sgx/main.c b/arch/x86/kernel/cpu/sgx/main.c
> > index 7df7048cb1c9..07bad864c531 100644
> > --- a/arch/x86/kernel/cpu/sgx/main.c
> > +++ b/arch/x86/kernel/cpu/sgx/main.c
> > @@ -1,6 +1,7 @@
> >  // SPDX-License-Identifier: GPL-2.0
> >  /*  Copyright(c) 2016-20 Intel Corporation. */
> >  
> > +#include <linux/debugfs.h>
> >  #include <linux/freezer.h>
> >  #include <linux/highmem.h>
> >  #include <linux/kthread.h>
> > @@ -25,7 +26,10 @@ static DECLARE_WAIT_QUEUE_HEAD(ksgxd_waitq);
> >  static LIST_HEAD(sgx_active_page_list);
> >  static DEFINE_SPINLOCK(sgx_reclaimer_lock);
> >  
> > -/* The free page list lock protected variables prepend the lock. */
> > +/* The number of EPC pages in total in all nodes. */
> > +static unsigned long sgx_nr_all_pages;
> > +
> > +/* The number of free EPC pages in all nodes. */
> >  static unsigned long sgx_nr_free_pages;
> 
> Ok, you're fixing the comment here. Good.

Should that be part of the first patch?

> Thx.
> 
> -- 
> Regards/Gruss,
>     Boris.
> 
> https://people.kernel.org/tglx/notes-about-netiquette
> 

/Jarkko

  reply	other threads:[~2021-04-07 16:09 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-05 23:26 [PATCH v2 1/2] x86/sgx: Do not update sgx_nr_free_pages in sgx_setup_epc_section() Jarkko Sakkinen
2021-04-05 23:26 ` [PATCH v2 2/2] x86/sgx: Add sgx_nr_{all, free}_pages to the debugfs Jarkko Sakkinen
2021-04-07 15:56   ` Borislav Petkov
2021-04-07 16:09     ` Jarkko Sakkinen [this message]
2021-04-07 16:15       ` Borislav Petkov
2021-04-08  8:52         ` Jarkko Sakkinen
2021-04-08  9:01           ` Borislav Petkov
2021-04-08  9:13           ` Jarkko Sakkinen
2021-04-08  9:32             ` Borislav Petkov
2021-04-08 16:27               ` Jarkko Sakkinen
2021-04-07 15:49 ` [PATCH v2 1/2] x86/sgx: Do not update sgx_nr_free_pages in sgx_setup_epc_section() Borislav Petkov
2021-04-07 16:03   ` Jarkko Sakkinen
2021-04-07 16:18     ` Borislav Petkov
2021-04-08  8:48       ` Jarkko Sakkinen
2021-04-08  8:56         ` Borislav Petkov
2021-04-08  9:22           ` Jarkko Sakkinen
2021-04-08  9:29             ` Borislav Petkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YG3ZJyMB+S5LcUso@kernel.org \
    --to=jarkko@kernel.org \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sgx@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.