lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <op.2id1c5n3wjvjmi@hhuan26-mobl.amr.corp.intel.com>
Date: Tue, 30 Jan 2024 19:35:19 -0600
From: "Haitao Huang" <haitao.huang@...ux.intel.com>
To: "jarkko@...nel.org" <jarkko@...nel.org>, "dave.hansen@...ux.intel.com"
 <dave.hansen@...ux.intel.com>, "tj@...nel.org" <tj@...nel.org>,
 "mkoutny@...e.com" <mkoutny@...e.com>, "linux-kernel@...r.kernel.org"
 <linux-kernel@...r.kernel.org>, "linux-sgx@...r.kernel.org"
 <linux-sgx@...r.kernel.org>, "x86@...nel.org" <x86@...nel.org>,
 "cgroups@...r.kernel.org" <cgroups@...r.kernel.org>, "tglx@...utronix.de"
 <tglx@...utronix.de>, "mingo@...hat.com" <mingo@...hat.com>, "bp@...en8.de"
 <bp@...en8.de>, "hpa@...or.com" <hpa@...or.com>, "Mehta, Sohil"
 <sohil.mehta@...el.com>, "Huang, Kai" <kai.huang@...el.com>
Cc: "Li, Zhiquan1" <zhiquan1.li@...el.com>, "kristen@...ux.intel.com"
 <kristen@...ux.intel.com>, "seanjc@...gle.com" <seanjc@...gle.com>, "Zhang,
 Bo" <zhanb@...rosoft.com>, "anakrish@...rosoft.com" <anakrish@...rosoft.com>,
 "mikko.ylinen@...ux.intel.com" <mikko.ylinen@...ux.intel.com>,
 "yangjie@...rosoft.com" <yangjie@...rosoft.com>, "chrisyan@...rosoft.com"
 <chrisyan@...rosoft.com>
Subject: Re: [PATCH v8 07/15] x86/sgx: Expose sgx_reclaim_pages() for cgroup

On Tue, 30 Jan 2024 09:39:44 -0600, Huang, Kai <kai.huang@...el.com> wrote:

>> + * @lru:	The LRU from which pages are reclaimed.
>> + * @nr_to_scan: Pointer to the target number of pages to scan, must be  
>> less
>> than
>> + *		SGX_NR_TO_SCAN.
>> + * Return:	Number of pages reclaimed.
>>   */
>> -static void sgx_reclaim_pages(void)
>> +unsigned int sgx_reclaim_pages(struct sgx_epc_lru_list *lru, unsigned
>> +int *nr_to_scan)
>
> Since the function is now returning the number of reclaimed pages, why  
> do you need to make the @nr_to_scan as pointer?
>
> Cannot the caller just adjust @nr_to_scan when calling this function  
> based on how many pages have reclaimed?
>
> I am not even sure whether you need @nr_to_scan at all because as we  
> discussed I think it's just extremely rare you need to pass "<  
> SGX_NR_TO_SCAN" to this function.
>
> Even if you need, you can always choose to try to reclaim SGX_NR_TO_SCAN  
> pages.
>

I tested with that approach and found we can only target number of pages  
attempted to reclaim not pages actually reclaimed due to the uncertainty  
of how long it takes to reclaim pages. Besides targeting number of scanned  
pages for each cycle is also what the ksgxd does.

If we target actual number of pages, sometimes it just takes too long. I  
saw more timeouts with the default time limit when running parallel  
selftests.

We also need return number of pages actually reclaimed as indication to  
caller whether we actually reclaimed any pages at all. The caller, e.g.,  
sgx_epc_cg_try_charge(), then can decide to schedule() or continue next  
step which usually is allocation of the page.

> [...]
>
>>
>> +static void sgx_reclaim_pages_global(void) {
>> +	unsigned int nr_to_scan = SGX_NR_TO_SCAN;
>> +
>> +	sgx_reclaim_pages(&sgx_global_lru, &nr_to_scan); }
>> +
>
> I think this function doesn't look sane at all when you have @nr_to_scan  
> being a pointer?
>

You will see the pointer being used later for cgroup worker.

> I am also not sure whether this function is needed -- if we don't add  
> @nr_to_scan to sgx_reclaim_pages(), then this function is basically:
>
> 	sgx_reclaim_pages(&sgx_global_lru);
>

As indicated in the commit message, this wrapper is getting ready for  
doing global reclamation from root cgroup. You will see it changed later.


Thanks
Haitao

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ