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: <87bk6i6lhk.fsf@yhuang6-desk2.ccr.corp.intel.com>
Date: Wed, 10 Apr 2024 09:43:19 +0800
From: "Huang, Ying" <ying.huang@...el.com>
To: Zhaoyu Liu <liuzhaoyu.zackary@...edance.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,  ryncsn@...il.com,
  nphamcs@...il.com,  songmuchun@...edance.com,  david@...hat.com,
  chrisl@...nel.org,  guo.ziliang@....com.cn,  yosryahmed@...gle.com,
  linux-kernel@...r.kernel.org,  linux-mm@...ck.org
Subject: Re: [PATCH v2] mm: swap: prejudgement swap_has_cache to avoid page
 allocation

Zhaoyu Liu <liuzhaoyu.zackary@...edance.com> writes:

> On Mon, Apr 08, 2024 at 01:27:04PM -0700, Andrew Morton wrote:
>> On Mon, 8 Apr 2024 20:14:39 +0800 Zhaoyu Liu <liuzhaoyu.zackary@...edance.com> wrote:
>> 
>> > Based on qemu arm64 - latest kernel + 100M memory + 1024M swapfile.
>> > Create 1G anon mmap and set it to shared, and has two processes
>> > randomly access the shared memory. When they are racing on swap cache,
>> > on average, each "alloc_pages_mpol + swapcache_prepare + folio_put"
>> > took about 1475 us.
>> 
>> And what effect does this patch have upon the measured time?  ANd upon
>> overall runtime?
>
> Hi Andrew,
>
> When share memory between two or more processes has swapped and pagefault now,
> it would readahead swap and call __read_swap_cache_async().
> If one of the processes calls swapcache_prepare() and finds that the cache 
> has been EXIST(another process added), it will folio_put on the basis of the 
> alloc_pages_mpol() that has been called, and then try filemap_get_folio() again.
>
> I think the page alloc in this process is wasteful.
> when the memory pressure is large, alloc_pages_mpol() will be time-consuming, 
> so the purpose of my patch is to judge whether the page has cache before page alloc, 
> then skip page alloc and retry filemap_get_folio() to save the time of the function.

Please prove your theory with data, better with benchmark score.

--
Best Regards,
Huang, Ying

>> 
>> > So skip page allocation if SWAP_HAS_CACHE was set, just
>> > schedule_timeout_uninterruptible and continue to acquire page
>> > via filemap_get_folio() from swap cache, to speedup
>> > __read_swap_cache_async.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ