* Re: [PATCH 1/2] SHM_UNLOCK: fix long unpreemptible section
[not found] ` <alpine.LSU.2.00.1201141615440.1338@eggly.anvils>
@ 2012-01-18 22:37 ` Andrew Morton
2012-01-18 23:26 ` Hugh Dickins
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Morton @ 2012-01-18 22:37 UTC (permalink / raw)
To: Hugh Dickins
Cc: KOSAKI Motohiro, Minchan Kim, Rik van Riel, Shaohua Li,
Eric Dumazet, Johannes Weiner, Michel Lespinasse, linux-kernel,
linux-mm, stable
On Sat, 14 Jan 2012 16:18:43 -0800 (PST)
Hugh Dickins <hughd@google.com> wrote:
> scan_mapping_unevictable_pages() is used to make SysV SHM_LOCKed pages
> evictable again once the shared memory is unlocked. It does this with
> pagevec_lookup()s across the whole object (which might occupy most of
> memory), and takes 300ms to unlock 7GB here. A cond_resched() every
> PAGEVEC_SIZE pages would be good.
>
> However, KOSAKI-san points out that this is called under shmem.c's
> info->lock, and it's also under shm.c's shm_lock(), both spinlocks.
> There is no strong reason for that: we need to take these pages off
> the unevictable list soonish, but those locks are not required for it.
>
> So move the call to scan_mapping_unevictable_pages() from shmem.c's
> unlock handling up to shm.c's unlock handling. Remove the recently
> added barrier, not needed now we have spin_unlock() before the scan.
>
> Use get_file(), with subsequent fput(), to make sure we have a
> reference to mapping throughout scan_mapping_unevictable_pages():
> that's something that was previously guaranteed by the shm_lock().
>
> Remove shmctl's lru_add_drain_all(): we don't fault in pages at
> SHM_LOCK time, and we lazily discover them to be Unevictable later,
> so it serves no purpose for SHM_LOCK; and serves no purpose for
> SHM_UNLOCK, since pages still on pagevec are not marked Unevictable.
>
> The original code avoided redundant rescans by checking VM_LOCKED
> flag at its level: now avoid them by checking shp's SHM_LOCKED.
>
> The original code called scan_mapping_unevictable_pages() on a
> locked area at shm_destroy() time: perhaps we once had accounting
> cross-checks which required that, but not now, so skip the overhead
> and just let inode eviction deal with them.
>
> Put check_move_unevictable_page() and scan_mapping_unevictable_pages()
> under CONFIG_SHMEM (with stub for the TINY case when ramfs is used),
> more as comment than to save space; comment them used for SHM_UNLOCK.
>
> Signed-off-by: Hugh Dickins <hughd@google.com>
> Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> Cc: stable@vger.kernel.org [back to 2.6.32 but will need respins]
Is -stable backporting really warranted? AFAICT the only thing we're
fixing here is a long latency glitch during a rare operation on large
machines. Usually it will be on only one CPU, too.
"[PATCH 2/2] SHM_UNLOCK: fix Unevictable pages stranded after swap"
does loko like -stable material, so omitting 1/1 will probably screw
things up :(
> Resend in the hope that it can get into 3.3.
That we can do ;)
>
> ...
>
> --- mmotm.orig/mm/vmscan.c 2012-01-06 10:04:54.000000000 -0800
> +++ mmotm/mm/vmscan.c 2012-01-06 10:06:13.941943604 -0800
> @@ -3499,6 +3499,7 @@ int page_evictable(struct page *page, st
> return 1;
> }
>
> +#ifdef CONFIG_SHMEM
> /**
> * check_move_unevictable_page - check page for evictability and move to appropriate zone lru list
> * @page: page to check evictability and move to appropriate lru list
> @@ -3509,6 +3510,8 @@ int page_evictable(struct page *page, st
> *
> * Restrictions: zone->lru_lock must be held, page must be on LRU and must
> * have PageUnevictable set.
> + *
> + * This function is only used for SysV IPC SHM_UNLOCK.
> */
> static void check_move_unevictable_page(struct page *page, struct zone *zone)
> {
> @@ -3545,6 +3548,8 @@ retry:
> *
> * Scan all pages in mapping. Check unevictable pages for
> * evictability and move them to the appropriate zone lru list.
> + *
> + * This function is only used for SysV IPC SHM_UNLOCK.
> */
> void scan_mapping_unevictable_pages(struct address_space *mapping)
> {
> @@ -3590,9 +3595,14 @@ void scan_mapping_unevictable_pages(stru
> pagevec_release(&pvec);
>
> count_vm_events(UNEVICTABLE_PGSCANNED, pg_scanned);
> + cond_resched();
> }
> -
> }
> +#else
> +void scan_mapping_unevictable_pages(struct address_space *mapping)
> +{
> +}
> +#endif /* CONFIG_SHMEM */
Inlining the CONFIG_SHMEM=n stub would have been mroe efficient.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 1/2] SHM_UNLOCK: fix long unpreemptible section
2012-01-18 22:37 ` [PATCH 1/2] SHM_UNLOCK: fix long unpreemptible section Andrew Morton
@ 2012-01-18 23:26 ` Hugh Dickins
0 siblings, 0 replies; 2+ messages in thread
From: Hugh Dickins @ 2012-01-18 23:26 UTC (permalink / raw)
To: Andrew Morton
Cc: KOSAKI Motohiro, Minchan Kim, Rik van Riel, Shaohua Li,
Eric Dumazet, Johannes Weiner, Michel Lespinasse, linux-kernel,
linux-mm, stable
On Wed, 18 Jan 2012, Andrew Morton wrote:
> On Sat, 14 Jan 2012 16:18:43 -0800 (PST)
> Hugh Dickins <hughd@google.com> wrote:
>
> > scan_mapping_unevictable_pages() is used to make SysV SHM_LOCKed pages
> > evictable again once the shared memory is unlocked. It does this with
> > pagevec_lookup()s across the whole object (which might occupy most of
> > memory), and takes 300ms to unlock 7GB here. A cond_resched() every
> > PAGEVEC_SIZE pages would be good.
>...
> Is -stable backporting really warranted? AFAICT the only thing we're
> fixing here is a long latency glitch during a rare operation on large
> machines. Usually it will be on only one CPU, too.
True: I'm not sure if it amounts to -stable material or not.
I see you've taken out its Cc: stable line: that's fine by me, but...
> "[PATCH 2/2] SHM_UNLOCK: fix Unevictable pages stranded after swap"
> does loko like -stable material, so omitting 1/1 will probably screw
> things up :(
Sort of, but they both(?) needed respinning for -stable anyway.
Even against 3.2, there's some little change in vmscan.c that generates
a reject. Greg has now closed down 3.1.N (which would have been tiresome
to port to, because it was still supporting a second caller of check_move),
and by your argument above it's not worth porting 1/2 back to 2.6.32. So
I think 2/2 can just go into 3.2.N, dragging 1/2 along in its slipstream
(if you can have a slipstream in front of you).
I ordered them that way because 1/2 fixes an old, and 2/2 a recent, bug.
> > Resend in the hope that it can get into 3.3.
>
> That we can do ;)
Thank you!
> > +#else
> > +void scan_mapping_unevictable_pages(struct address_space *mapping)
> > +{
> > +}
> > +#endif /* CONFIG_SHMEM */
>
> Inlining the CONFIG_SHMEM=n stub would have been mroe efficient.
True, though in 2/2 it morphs into shmem_unlock_mapping() over
in shmem.c, and we seem to have the convention that TINY's !SHMEM
stubs live as non-inline functions there - probably no good reason
for that, just reflects their historical origins in tiny-shmem.c.
A grand saving to make some other time ;)
Hugh
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-01-18 23:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <alpine.LSU.2.00.1201061303320.12082@eggly.anvils>
[not found] ` <alpine.LSU.2.00.1201141615440.1338@eggly.anvils>
2012-01-18 22:37 ` [PATCH 1/2] SHM_UNLOCK: fix long unpreemptible section Andrew Morton
2012-01-18 23:26 ` Hugh Dickins
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox