linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Hugh Dickins <hughd@google.com>
Cc: cgel.zte@gmail.com, naoya.horiguchi@nec.com, mhocko@kernel.org,
	minchan@kernel.org, hannes@cmpxchg.org, rogerq@kernel.org,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	guo.ziliang@zte.com.cn, Zeal Robot <zealci@zte.com.cn>,
	Ran Xiaokai <ran.xiaokai@zte.com.cn>,
	Jiang Xuexin <jiang.xuexin@zte.com.cn>,
	Yang Yang <yang.yang29@zte.com.cn>
Subject: Re: [PATCH linux-next] mm: swap: get rid of deadloop in swapin readahead
Date: Tue, 1 Mar 2022 16:32:43 -0800	[thread overview]
Message-ID: <20220301163243.33e8fc82e567512e54a78560@linux-foundation.org> (raw)
In-Reply-To: <b2715e40-dc61-1589-de19-ea4c3bd3f674@google.com>

On Mon, 28 Feb 2022 20:07:33 -0800 (PST) Hugh Dickins <hughd@google.com> wrote:

> > > --- a/mm/swap_state.c
> > > +++ b/mm/swap_state.c
> > > @@ -478,7 +478,7 @@ struct page *__read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,
> > >  		 * __read_swap_cache_async(), which has set SWAP_HAS_CACHE
> > >  		 * in swap_map, but not yet added its page to swap cache.
> > >  		 */
> > > -		cond_resched();
> > > +		schedule_timeout_uninterruptible(1);
> > >  	}
> > >  
> > >  	/*
> > 
> > Sigh.  I guess yes, we should do this, at least in a short-term,
> > backportable-to-stable way.
> > 
> > But busy-waiting while hoping that someone else will save us isn't an
> > attractive design.  Hugh, have you ever thought about something more
> > deterministic in there?
> 
> Not something more deterministic, no: I think that would entail
> heavier locking, perhaps slowing down hotter paths, just to avoid
> this swap oddity.
> 
> This loop was written long before there was a preemptive kernel:
> it was appropriate then, and almost never needed more than one retry
> to complete; but preemption changed the story without us realizing.
> 
> Sigh here too.  I commend the thread on it from July 2018:
> https://lore.kernel.org/linux-mm/2018072514403228778860@wingtech.com/
> 
> There the 4.9-stable user proposed preempt_disable(), I agreed but
> found the patch provided insufficient, and offered another 4.9 patch
> further down the thread.  Your preference at the time was msleep(1).
> 
> I was working on a similar patch for 4.18, but have not completed it
> yet ;) and don't remember how satisfied or not I was with that one;
> and wonder if I'm any more likely to get it finished by 2026.  It's
> clear that I put much more thought into it back then than just now.
> 
> Maybe someone else would have a go: my 4.9 patch in that thread
> shows most of it, but might need a lot of work to update to 5.17.
> 
> And it also gathered some temporary debug stats on how often this
> happens: I'm not conscious of using RT at all, but was disturbed to see
> how long an ordinary preemptive kernel was sometimes spinning there.
> So I think I agree with you more than Michal on that: RT just makes
> the bad behaviour more obvious.

Thanks as always.

Using msleep() seems pretty pointless so I plan to go ahead with patch
as-is, with a cc:stable.  None of it is pretty, but it's better than
what we have now, yes?



  reply	other threads:[~2022-03-02  0:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-21 11:17 cgel.zte
2022-02-26  1:24 ` Andrew Morton
2022-03-01  4:07   ` Hugh Dickins
2022-03-02  0:32     ` Andrew Morton [this message]
2022-03-02 19:31       ` Hugh Dickins
2022-02-28  7:57 ` Michal Hocko
2022-02-28 15:33   ` Andrew Morton
2022-03-02  9:46     ` Michal Hocko
2022-03-02 20:38       ` Hugh Dickins

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=20220301163243.33e8fc82e567512e54a78560@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=cgel.zte@gmail.com \
    --cc=guo.ziliang@zte.com.cn \
    --cc=hannes@cmpxchg.org \
    --cc=hughd@google.com \
    --cc=jiang.xuexin@zte.com.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=minchan@kernel.org \
    --cc=naoya.horiguchi@nec.com \
    --cc=ran.xiaokai@zte.com.cn \
    --cc=rogerq@kernel.org \
    --cc=yang.yang29@zte.com.cn \
    --cc=zealci@zte.com.cn \
    /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