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]
Date:   Wed, 11 Oct 2017 16:10:34 +0800
From:   "Huang\, Ying" <ying.huang@...el.com>
To:     Minchan Kim <minchan@...nel.org>
Cc:     "Huang\, Ying" <ying.huang@...el.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        <linux-mm@...ck.org>, <linux-kernel@...r.kernel.org>,
        Johannes Weiner <hannes@...xchg.org>,
        "Rik van Riel" <riel@...hat.com>, Shaohua Li <shli@...nel.org>,
        Hugh Dickins <hughd@...gle.com>,
        Fengguang Wu <fengguang.wu@...el.com>,
        Tim Chen <tim.c.chen@...el.com>,
        Dave Hansen <dave.hansen@...el.com>
Subject: Re: [PATCH -mm -v2] mm, swap: Use page-cluster as max window of VMA based swap readahead

Minchan Kim <minchan@...nel.org> writes:

> On Wed, Oct 11, 2017 at 03:08:47PM +0800, Huang, Ying wrote:
>> From: Huang Ying <ying.huang@...el.com>
>> 
>> When the VMA based swap readahead was introduced, a new knob
>> 
>>   /sys/kernel/mm/swap/vma_ra_max_order
>> 
>> was added as the max window of VMA swap readahead.  This is to make it
>> possible to use different max window for VMA based readahead and
>> original physical readahead.  But Minchan Kim pointed out that this
>> will cause a regression because setting page-cluster sysctl to zero
>> cannot disable swap readahead with the change.
>> 
>> To fix the regression, the page-cluster sysctl is used as the max
>> window of both the VMA based swap readahead and original physical swap
>> readahead.  If more fine grained control is needed in the future, more
>> knobs can be added as the subordinate knobs of the page-cluster
>> sysctl.
>> 
>> The vma_ra_max_order knob is deleted.  Because the knob was
>> introduced in v4.14-rc1, and this patch is targeting being merged
>> before v4.14 releasing, there should be no existing users of this
>> newly added ABI.
>> 
>> Cc: Johannes Weiner <hannes@...xchg.org>
>> Cc: Rik van Riel <riel@...hat.com>
>> Cc: Shaohua Li <shli@...nel.org>
>> Cc: Hugh Dickins <hughd@...gle.com>
>> Cc: Fengguang Wu <fengguang.wu@...el.com>
>> Cc: Tim Chen <tim.c.chen@...el.com>
>> Cc: Dave Hansen <dave.hansen@...el.com>
>> Reported-by: Minchan Kim <minchan@...nel.org>
>> Signed-off-by: "Huang, Ying" <ying.huang@...el.com>
>
> Acked-by: Minchan Kim <minchan@...nel.org>

Thanks!

> Below a question:
>
>> ---
>>  Documentation/ABI/testing/sysfs-kernel-mm-swap | 10 -------
>>  mm/swap_state.c                                | 41 +++++---------------------
>>  2 files changed, 7 insertions(+), 44 deletions(-)
>> 
>> diff --git a/Documentation/ABI/testing/sysfs-kernel-mm-swap b/Documentation/ABI/testing/sysfs-kernel-mm-swap
>> index 587db52084c7..94672016c268 100644
>> --- a/Documentation/ABI/testing/sysfs-kernel-mm-swap
>> +++ b/Documentation/ABI/testing/sysfs-kernel-mm-swap
>> @@ -14,13 +14,3 @@ Description:	Enable/disable VMA based swap readahead.
>>  		still used for tmpfs etc. other users.  If set to
>>  		false, the global swap readahead algorithm will be
>>  		used for all swappable pages.
>> -
>> -What:		/sys/kernel/mm/swap/vma_ra_max_order
>> -Date:		August 2017
>> -Contact:	Linux memory management mailing list <linux-mm@...ck.org>
>> -Description:	The max readahead size in order for VMA based swap readahead
>> -
>> -		VMA based swap readahead algorithm will readahead at
>> -		most 1 << max_order pages for each readahead.  The
>> -		real readahead size for each readahead will be scaled
>> -		according to the estimation algorithm.
>> diff --git a/mm/swap_state.c b/mm/swap_state.c
>> index ed91091d1e68..05b6803f0cce 100644
>> --- a/mm/swap_state.c
>> +++ b/mm/swap_state.c
>> @@ -39,10 +39,6 @@ struct address_space *swapper_spaces[MAX_SWAPFILES];
>>  static unsigned int nr_swapper_spaces[MAX_SWAPFILES];
>>  bool swap_vma_readahead = true;
>>  
>> -#define SWAP_RA_MAX_ORDER_DEFAULT	3
>> -
>> -static int swap_ra_max_order = SWAP_RA_MAX_ORDER_DEFAULT;
>> -
>>  #define SWAP_RA_WIN_SHIFT	(PAGE_SHIFT / 2)
>>  #define SWAP_RA_HITS_MASK	((1UL << SWAP_RA_WIN_SHIFT) - 1)
>>  #define SWAP_RA_HITS_MAX	SWAP_RA_HITS_MASK
>> @@ -664,6 +660,13 @@ struct page *swap_readahead_detect(struct vm_fault *vmf,
>>  	pte_t *tpte;
>>  #endif
>>  
>> +	max_win = 1 << min_t(unsigned int, READ_ONCE(page_cluster),
>> +			     SWAP_RA_ORDER_CEILING);
>
> Why do we need READ_ONCE in here? IOW, without it, what happens?

Per my understanding, this is to make sure that the compiler will
generate the code to read the memory really.  To avoid some compiler
optimization like cache in register or constant optimization.

Best Regards,
Huang, Ying

>> +	if (max_win == 1) {
>> +		swap_ra->win = 1;
>> +		return NULL;
>> +	}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ