Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp418837pxm; Wed, 2 Mar 2022 00:52:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJxFA3usCPWdXV9ik6YYOGorHjWj1wJVik1US54+DgmR9fUX+6Z6wFrTzDD4ISVfGvdW5HJZ X-Received: by 2002:a17:906:a152:b0:6cd:3098:18c9 with SMTP id bu18-20020a170906a15200b006cd309818c9mr22236829ejb.422.1646211130551; Wed, 02 Mar 2022 00:52:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646211130; cv=none; d=google.com; s=arc-20160816; b=ex8Mo/eLaHn3QGyY34lGf54aTff2l5jtgqEESJebD/cS2DFs3tZ1vbopDPdVxtYnKD gAcIcKUwd+Piih7LdDfHMIbttaBlngTme3y1ZN50/BXmp71aGWeFTRuiO0MYdXU5Y2tz x3duJ5qdUegjRhqcH3zjhnQWELe/nQJPcfrMJI5G9rFUk0fWAZwQ38a/Z3T8ZiwzjnLt mJ8NDo6dZnkoKq5r7TU9aI/B+VrX0yKbcXtto5oX9SpjNv6cq2C9YiEC8l76lx2PA1EN ig6U0ajxcMAtd/CNV2M/r7R1gBiYuQuR/UOnQa7IyLiTW72GlMjbc9PZnW852+h2S5As 3kVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=Vpr+fQadJO8v3+z0Telz4QdGiuTIQB8YT7Z4Kf0Qwn4=; b=oAhnT4qw0BLIAtMXProYXL5O1bXi0lEZDN99FKg3ahvP6GZq4K0P0pkmYtVtqeUwRn djSmc9BSqEnP0IpCRVXUwbRrP2miygEB/b975owTS8i54hadMBcCUU+yJpESph8+7kjv dr24mFzXgd9+s8tcu/3z5RviXtoqNi4SutRUwo+guOvEJkYUSPrSXgabmPoJMldb6adJ HWD642uS0uvQD4i8BHpyM6x/FTvhAHelzJZeIIxiSlOi/YDHfB7Rzzfv98rTF1VtORKn rwd7x1rKAIHeL4dd+zZ8Rq8LFokq1jh2c+SVNosS0M/P8RcA67d+gerIwp0ia3Ys4huo IPmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=lEyApmR8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o14-20020a170906974e00b006d9f7749d0esi924578ejy.841.2022.03.02.00.51.47; Wed, 02 Mar 2022 00:52:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=lEyApmR8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238739AbiCBAd1 (ORCPT + 99 others); Tue, 1 Mar 2022 19:33:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229792AbiCBAd1 (ORCPT ); Tue, 1 Mar 2022 19:33:27 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B47FC9FC0 for ; Tue, 1 Mar 2022 16:32:45 -0800 (PST) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 45F2361506 for ; Wed, 2 Mar 2022 00:32:45 +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-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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?