Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp851020ybh; Wed, 22 Jul 2020 15:11:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6OTW1bWvjuGqdS6NgaPP8ke1ErEGDVVAvSa8Dn+r1QBm+NOM0WzadVl9S1cmeCLif2xkK X-Received: by 2002:a17:906:3e13:: with SMTP id k19mr1574661eji.476.1595455900957; Wed, 22 Jul 2020 15:11:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595455900; cv=none; d=google.com; s=arc-20160816; b=aRDRBbU7T7FYa7+hwOcX8NdwsD6gxmCjnRqfign1/tLCHio8F9e4AUVzVP2hJumNUP 5hDj0R32UDdlpyeObsoSomAfqtNxkgyx+SfIiWl4/G17EuBFolsnnfZIfWUNSXwicxR/ KniGyNCG+Xq8yNgNHMj7l7U6D8HD9KL19WkEhCXid8Bhbx5LN3QbaFguz/WDZGpdgvGY 250vAcJfwsjmcNlxlguYKXNOlSXFz4mMZCG0AqdeK+aN5qSCc0eSU5C4XWyFCYAKGGBc 11EYriHlUagmzAXCzTkcq6eILzPMpPMftsyQoKP0/pZ5uDTchh02ofihUDXG8bCmDsjf 43Vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=mKcnks++BVJckGT27RdKRDX4KPgvtTbjBQBJPx6EVtE=; b=miJHWApbjNZSmdiuMTESZmt5EBriziEPRkYj+24LAiEgCpGm6nTzjbdJTB55aWxLpf ZJ/Qgr7bIqDwhXsbnfpdUQiB32AHRDs6I47Hs/9As5hVCMOr954O69mTi4Yc/T8Jt+gT uH99nLO0D6EutKczFvlViE8mBqliGGxfavX4phYBd0LvBy6842A7HNU4e7bCET0p5nyE yGQCMcyhSh7LZKCSOcZD/OoOdHrrkNwZEasAfVj/Ydm+9eFh8b1Qq78kzEP8oDEFCg5B Yit5uGj89l1DOkpkkrQekvKKQbrnk2tSw/wmaJExXdvSxoyLh1tQaoeWVxz+OYAEFG8f Uu+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=HfjxMSNX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bo4si807148ejb.279.2020.07.22.15.11.16; Wed, 22 Jul 2020 15:11:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=HfjxMSNX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730153AbgGVWLF (ORCPT + 99 others); Wed, 22 Jul 2020 18:11:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726642AbgGVWLF (ORCPT ); Wed, 22 Jul 2020 18:11:05 -0400 Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8921DC0619DC for ; Wed, 22 Jul 2020 15:11:04 -0700 (PDT) Received: by mail-lf1-x141.google.com with SMTP id u12so2213426lff.2 for ; Wed, 22 Jul 2020 15:11:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mKcnks++BVJckGT27RdKRDX4KPgvtTbjBQBJPx6EVtE=; b=HfjxMSNXOBFs72NZQwzgLB+n1HTdUhb2cUmrKtKW+8eiwn4OoCtnYZdYaBLyuKrcQk UfOFr2okT+3ozHOJ2IfVHuWgMZEiY+vOc8DmYBkD/QLBRZQfVAs94sB2DMASW5ElGu2q P25unJrMLZmaAUjrKbNr8RMGKLunq02CX9d4s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mKcnks++BVJckGT27RdKRDX4KPgvtTbjBQBJPx6EVtE=; b=Jf+e5iFKL5zj4MqLUaAmMLorS76CiFnrJw1SUPZwlxkhaet9Pauj4FHrlFIRmKWACJ Q7ShBZTef0lSL7nlG+OTP29KolTlpx8A5BpYCPBCtVqcUpDDoL38M8IoRxi3RfXcFlmG kcmMfhNzDROIZEoGaYWlGOR3r//CJx91ZfEiVJEZ/kTh37hIq1D4vDC4WkOLDmJZKv8k nctOblvJdABifkUsSvFIYbdxUgqb1YVcsU6/d1K/AQcjE7bau/9S/fp1rAclnGNgjjcU q97WhBSfY+ebeNdMl/zkFJB+akSMGqnJ7grxyvE5k+uKhckJHNtVg05Uv6xHIKh+szV+ Cpqg== X-Gm-Message-State: AOAM530gmuoWAH5INaXlBvsYtA/ctE9TJei1xuIm8KwqATgB9n2e0oGZ HRE+EG8awONpc9FipgJB9lWaPtM+5K4= X-Received: by 2002:a05:6512:74b:: with SMTP id c11mr654342lfs.119.1595455862650; Wed, 22 Jul 2020 15:11:02 -0700 (PDT) Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com. [209.85.167.53]) by smtp.gmail.com with ESMTPSA id 2sm893935lfr.48.2020.07.22.15.11.01 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Jul 2020 15:11:01 -0700 (PDT) Received: by mail-lf1-f53.google.com with SMTP id b30so2185137lfj.12 for ; Wed, 22 Jul 2020 15:11:01 -0700 (PDT) X-Received: by 2002:ac2:58d5:: with SMTP id u21mr673351lfo.31.1595455860915; Wed, 22 Jul 2020 15:11:00 -0700 (PDT) MIME-Version: 1.0 References: <20200721063258.17140-1-mhocko@kernel.org> In-Reply-To: From: Linus Torvalds Date: Wed, 22 Jul 2020 15:10:44 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH] mm: silence soft lockups from unlock_page To: Hugh Dickins Cc: Michal Hocko , Linux-MM , LKML , Andrew Morton , Tim Chen , Michal Hocko Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 22, 2020 at 2:29 PM Hugh Dickins wrote: > > -#define PAGE_WAIT_TABLE_BITS 8 > +#define PAGE_WAIT_TABLE_BITS 10 Well, that seems harmless even on small machines. > + bool first_time = true; > bool thrashing = false; > bool delayacct = false; > unsigned long pflags; > @@ -1134,7 +1135,12 @@ static inline int wait_on_page_bit_commo > spin_lock_irq(&q->lock); > > if (likely(list_empty(&wait->entry))) { > - __add_wait_queue_entry_tail(q, wait); > + if (first_time) { > + __add_wait_queue_entry_tail(q, wait); > + first_time = false; > + } else { > + __add_wait_queue(q, wait); > + } > SetPageWaiters(page); > } This seems very hacky. And in fact, looking closer, I'd say that there are more serious problems here. Look at that WQ_FLAG_EXCLUSIVE thing: non-exclusive waits should always go at the head (because they're not going to steal the bit, they just want to know when it got cleared), and exclusive waits should always go at the tail (because of fairness). But that's not at all what we do. Your patch adds even more confusion to this nasty area. And your third one: > + if (ret) > + woken++; > > - if (bookmark && (++cnt > WAITQUEUE_WALK_BREAK_CNT) && > + if (bookmark && (++cnt > WAITQUEUE_WALK_BREAK_CNT) && woken && I've got two reactions to this (a) we should not need a new "woken" variable, we should just set a high bit of "cnt" and make WAITQUEUE_WALK_BREAK_CNT contain that high bit (Tune "high bit" to whatever you want: it could be either the _real_ high bit of the variable, or it could be something like "128", which would mean that you'd break out after 128 non-waking entries). (b) Ugh, what hackery and magic behavior regardless I'm really starting to hate that wait_on_page_bit_common() function. See a few weeks ago how the function looks buggy to begin with https://lore.kernel.org/lkml/CAHk-=wjJA2Z3kUFb-5s=6+n0qbTs8ELqKFt9B3pH85a8fGD73w@mail.gmail.com/ and that never got resolved either (but probably never happens in practice). Linus