From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70628C433F5 for ; Wed, 2 Mar 2022 00:32:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 99B558D0002; Tue, 1 Mar 2022 19:32:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 94B428D0001; Tue, 1 Mar 2022 19:32:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 83A138D0002; Tue, 1 Mar 2022 19:32:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0099.hostedemail.com [216.40.44.99]) by kanga.kvack.org (Postfix) with ESMTP id 725CE8D0001 for ; Tue, 1 Mar 2022 19:32:50 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 22750181CA334 for ; Wed, 2 Mar 2022 00:32:50 +0000 (UTC) X-FDA: 79197570900.25.F6E24DC Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf25.hostedemail.com (Postfix) with ESMTP id A7290A0002 for ; Wed, 2 Mar 2022 00:32:50 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 0DE29B81ECD; Wed, 2 Mar 2022 00:32:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35F57C340EE; Wed, 2 Mar 2022 00:32:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1646181164; bh=hsN8LPpCJcyecCitmc0hAjyVwKbdXCBm88fiaaIV8mA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=lEyApmR8z17UqqiscwiebeBSFFRYAKrvU0EKctGxXbp7r7bIlM2MAk+iqVfWD8wBZ bcnTgw2SSTzytsigv6XSOFo1M9iFUJRHPuFjwBRJbaGHxxO7R6mV6KoA5wwBodfMnk Gp6Dw/xpZ2HpkhieTHPXYb8u9ifhDhX7y6Oygdg0= Date: Tue, 1 Mar 2022 16:32:43 -0800 From: Andrew Morton To: Hugh Dickins 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 , Ran Xiaokai , Jiang Xuexin , Yang Yang Subject: Re: [PATCH linux-next] mm: swap: get rid of deadloop in swapin readahead Message-Id: <20220301163243.33e8fc82e567512e54a78560@linux-foundation.org> In-Reply-To: References: <20220221111749.1928222-1-cgel.zte@gmail.com> <20220225172440.ec62edf97b405d32061bcb37@linux-foundation.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: A7290A0002 X-Stat-Signature: gr66i4f48qbxpp9gqg9bpg1jsr3dsekq X-Rspam-User: Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=lEyApmR8; dmarc=none; spf=pass (imf25.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-Rspamd-Server: rspam03 X-HE-Tag: 1646181170-548643 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, 28 Feb 2022 20:07:33 -0800 (PST) Hugh Dickins 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?