From: "Huang, Kai" <kai.huang@intel.com>
To: "Mehta, Sohil" <sohil.mehta@intel.com>,
"mingo@redhat.com" <mingo@redhat.com>,
"jarkko@kernel.org" <jarkko@kernel.org>,
"x86@kernel.org" <x86@kernel.org>,
"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
"cgroups@vger.kernel.org" <cgroups@vger.kernel.org>,
"hpa@zytor.com" <hpa@zytor.com>,
"tim.c.chen@linux.intel.com" <tim.c.chen@linux.intel.com>,
"linux-sgx@vger.kernel.org" <linux-sgx@vger.kernel.org>,
"mkoutny@suse.com" <mkoutny@suse.com>,
"haitao.huang@linux.intel.com" <haitao.huang@linux.intel.com>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"tj@kernel.org" <tj@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"bp@alien8.de" <bp@alien8.de>
Cc: "mikko.ylinen@linux.intel.com" <mikko.ylinen@linux.intel.com>,
"seanjc@google.com" <seanjc@google.com>,
"anakrish@microsoft.com" <anakrish@microsoft.com>,
"Zhang, Bo" <zhanb@microsoft.com>,
"kristen@linux.intel.com" <kristen@linux.intel.com>,
"yangjie@microsoft.com" <yangjie@microsoft.com>,
"Li, Zhiquan1" <zhiquan1.li@intel.com>,
"chrisyan@microsoft.com" <chrisyan@microsoft.com>
Subject: Re: [PATCH v15 08/14] x86/sgx: Add basic EPC reclamation flow for cgroup
Date: Thu, 20 Jun 2024 22:52:26 +0000 [thread overview]
Message-ID: <47c86959a6e18730b1dfacecbdad4bad991f7a5b.camel@intel.com> (raw)
In-Reply-To: <op.2pn9nlapwjvjmi@hhuan26-mobl.amr.corp.intel.com>
> >
> > > In other cases, the caller may invoke this function in a
> > > loop to ensure enough pages reclaimed for its usage. To ensure all
> > > descendant groups scanned in a round-robin fashion in those cases,
> > > sgx_cgroup_reclaim_pages() takes in a starting cgroup and returns the
> > > next cgroup that the caller can pass in as the new starting cgroup for a
> > > subsequent call.
> >
> >
> > AFAICT this part is new, and I believe this "round-robin" thing is just
> > for the "global reclaim"? Or is it also for per-cgroup reclaim where
> > more
> > than SGX_NR_TO_SCAN pages needs to be reclaimed?
> >
> > I wish the changelog should just point out what consumers will use this
> > new sgx_cgroup_reclaim_pages(), like:
> >
> > The sgx_cgroup_reclaim_pages() will be used in three cases:
> >
> > 1) direct/sync per-cgroup reclaim in try_charge()
> > 2) indirect/async per-cgroup reclaim triggered in try_charge()
> > 3) global reclaim
> >
> > And then describe how will they use sgx_cgroup_reclaim_pages():
> >
> > Both 1) and 2) can result in needing to reclaim more than SGX_NR_TO_SCAN
> > pages, in which case we should <fill in how to reclaim>.
> >
> > For 3), the new global reclaim should try tot match the existing global
> > reclaim behaviour, that is to try to treat all EPC pages equally.
> > <continue to explain how can sgx_cgroup_reclaim_pages() achieve this.>
> >
> > With above context, we can justify why to make sgx_cgroup_reclaim_pages()
> > in this form.
> >
> This new part is only to address the issue you raised in this thread:
> https://lore.kernel.org/lkml/op.2ndsydgywjvjmi@hhuan26-mobl.amr.corp.intel.com/
>
> Really it has nothing to do whether global, direct/async, per-cgroup
> contexts. They all should use the function the same way. This paragraph
> describes the design and
> I thought the above new statements justify the reason we return 'next' so
> it can reclaim into descedant in round-robin fashion? No sure we need get
> into details of different usages of the functions which are in code
> actually?
Please clearly define the behaviour of "per-cgroup reclaim" first.
I can understand "global reclaim" means we essentially want to treats all
EPC pages equally. But it's not obvious to me what is the desired
behaviour of "per-cgroup reclaim", especially when the behaviour is
different between this version and the previous versions (see below).
>
[...]
> > And when there are more than SGX_NR_TO_SCAN pages that need to reclaim,
> > the above ...
>
> Note, all sgx_cgroup_reclaim_pages() guarantees is scanning SGX_NR_TO_SCAN
> pages.
> >
> > for (;;) {
> > cg_next = sgx_cgroup_reclaim_pages(sgx_cg->cg, cg_next);
> > }
> >
> > ... actually tries to reclaim those pages from @sgx_cg _AND_ it's
> > descendants, and tries to do it _EQUALLY_.
> >
> > Is this desired, or should we always try to reclaim from the @sgx_cg
> > first, but only moves to the desendants when the @sgx_cg shouldn't be
> > reclaimed anymore?
> >
>
> we still reclaim in sgx_cg in first scan and attempt of reclaiming for
> SGX_NR_TOS_CAN pages, but if it turns out that did not satisfy caller
> needs, then caller goes on to reclaim from descendants by passing in
> 'next' as starting point.
But why?
>
> > Anyway, it's different from the previous behaviour.
> >
> Again, this is to fix the issue you raised. I consider it improved
> behavior :-)
Please clearly define the _EXPECTED_ hebaviour of "per-cgroup reclaim"
first.
>
We have two choices:
1) Always try to reclaim desired number of pages from the given cgroup,
but only moves to reclaim from descendants when there's less than
SGX_NR_TO_SCAN pages left;
2) Always try to reclaim desired number of pages _EQUALLY_ from the given
cgroup _AND_ its descendants (in granularity of reclaiming SGX_NR_TO_SCAN
pages each time).
The 1) was the old behavour in the previous versions, 2) is the new
behaviour in this version.
I am not against any option, but the patch needs to be clear on which
option to choose and why it is desired/better.
next prev parent reply other threads:[~2024-06-20 22:52 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-17 12:53 [PATCH v15 00/14] Add Cgroup support for SGX EPC memory Huang, Haitao
2024-06-17 12:53 ` [PATCH v15 01/14] x86/sgx: Replace boolean parameters with enums Huang, Haitao
2024-06-17 12:53 ` [PATCH v15 02/14] cgroup/misc: Add per resource callbacks for CSS events Huang, Haitao
2024-06-17 12:53 ` [PATCH v15 03/14] cgroup/misc: Export APIs for SGX driver Huang, Haitao
2024-06-17 12:53 ` [PATCH v15 04/14] cgroup/misc: Add SGX EPC resource type Huang, Haitao
2024-06-17 12:53 ` [PATCH v15 05/14] x86/sgx: Implement basic EPC misc cgroup functionality Huang, Haitao
2024-06-18 11:31 ` Huang, Kai
2024-06-18 12:56 ` Haitao Huang
2024-06-18 23:15 ` Huang, Kai
2024-06-18 23:23 ` Haitao Huang
2024-06-19 2:00 ` Huang, Kai
2024-06-17 12:53 ` [PATCH v15 06/14] x86/sgx: Add sgx_epc_lru_list to encapsulate LRU list Huang, Haitao
2024-06-17 12:53 ` [PATCH v15 07/14] x86/sgx: Abstract tracking reclaimable pages in LRU Huang, Haitao
2024-06-17 12:53 ` [PATCH v15 08/14] x86/sgx: Add basic EPC reclamation flow for cgroup Huang, Haitao
2024-06-20 13:28 ` Huang, Kai
2024-06-20 16:05 ` Haitao Huang
2024-06-20 22:52 ` Huang, Kai [this message]
2024-06-17 12:53 ` [PATCH v15 09/14] x86/sgx: Abstract check for global reclaimable pages Huang, Haitao
2024-06-17 12:53 ` [PATCH v15 10/14] x86/sgx: Implement async reclamation for cgroup Huang, Haitao
2024-06-20 15:39 ` Haitao Huang
2024-06-17 12:53 ` [PATCH v15 11/14] x86/sgx: Charge mem_cgroup for per-cgroup reclamation Huang, Haitao
2024-06-17 12:53 ` [PATCH v15 12/14] x86/sgx: Turn on per-cgroup EPC reclamation Huang, Haitao
2024-06-20 10:30 ` Huang, Kai
2024-06-20 15:06 ` Haitao Huang
2024-06-20 23:53 ` Huang, Kai
2024-06-17 12:53 ` [PATCH v15 13/14] Docs/x86/sgx: Add description for cgroup support Huang, Haitao
2024-06-17 12:53 ` [PATCH v15 14/14] selftests/sgx: Add scripts for EPC cgroup testing Huang, Haitao
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=47c86959a6e18730b1dfacecbdad4bad991f7a5b.camel@intel.com \
--to=kai.huang@intel.com \
--cc=anakrish@microsoft.com \
--cc=bp@alien8.de \
--cc=cgroups@vger.kernel.org \
--cc=chrisyan@microsoft.com \
--cc=dave.hansen@linux.intel.com \
--cc=haitao.huang@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jarkko@kernel.org \
--cc=kristen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sgx@vger.kernel.org \
--cc=mikko.ylinen@linux.intel.com \
--cc=mingo@redhat.com \
--cc=mkoutny@suse.com \
--cc=seanjc@google.com \
--cc=sohil.mehta@intel.com \
--cc=tglx@linutronix.de \
--cc=tim.c.chen@linux.intel.com \
--cc=tj@kernel.org \
--cc=x86@kernel.org \
--cc=yangjie@microsoft.com \
--cc=zhanb@microsoft.com \
--cc=zhiquan1.li@intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox