Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp901875ybh; Wed, 22 Jul 2020 16:43:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOJmeyF6htY7NjlmbvUQCkV3JHnZW+2wJcURJOE00/O3IQ1oaVhs1Ov3OWYMIwmLuDjvqX X-Received: by 2002:a17:906:7a46:: with SMTP id i6mr1758130ejo.475.1595461433943; Wed, 22 Jul 2020 16:43:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595461433; cv=none; d=google.com; s=arc-20160816; b=Olu8ZJ+HNzinR5fbQ9a8mD/e1/RoB8vEHCcXur2krI6j6SPEOZB5gUBLHDCi28cS6/ wb69qsvGxE2ZqL6WzfQS7Xsp2lIXupqFt/WLnLlqIZS2ryiAeSzDuAJqkCQkTEoXRr0Y WzWJWvp+xOTLT4/hpnN0fw3GY6KzLvQw6drJJ/P+gaW/o+ajD5JRC4IBoCN24bmamuli 6Lgh/f761nEKI+4HPoZXxmFWXT7VSzYKTVxGmvHAFSY0CtaFFCBtmvEqpsWcxBz8iwNa 2Wz8F4g8nuMqk8WX62UseitiMDnFfIm7i0G+R3nZfDf+Ry4+LyhJgZaAYALG5YGEHdPX GlqQ== 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=1gorWaBOTDzwkFhAp9D2nVno0BUb+tV20gLZenZj/T4=; b=kUej9NHPz/RAuo552Dy6mwlzbXzftAxP9d4llq1AoxQTbu1viJGBMQnBBB7THK+qN5 c+rzi0dQqbGi3FbdxXrWc9KFmEIYJroTr6nYLDse4Y7Iyd39db7r++Yb1QikCknWdArb zi/SH1/1omKhOAkDqx2/UHqOK6tnsL8OdlYYi79jE5In2kp0nJLfZhT08iEcyYPT+kVU QJOW+xyyl9aIlcZXrFqld9gvN+NF+k5QHHqCkPEEYYNDW/mwS1qPLMDeWCimEH/Ui2ks X0I7bKB5Yq4RR5pRrM2oJeF1KKLtNLB247Crbbotn270gWUut6JuqxZe5VXMqvbz11Xd KM/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b="ho/W69t/"; 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 u6si908463edy.584.2020.07.22.16.43.31; Wed, 22 Jul 2020 16:43:53 -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="ho/W69t/"; 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 S1733052AbgGVXmz (ORCPT + 99 others); Wed, 22 Jul 2020 19:42:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733039AbgGVXmz (ORCPT ); Wed, 22 Jul 2020 19:42:55 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97584C0619DC for ; Wed, 22 Jul 2020 16:42:54 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id f5so4383699ljj.10 for ; Wed, 22 Jul 2020 16:42:54 -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=1gorWaBOTDzwkFhAp9D2nVno0BUb+tV20gLZenZj/T4=; b=ho/W69t/YxXGLh0XaFKt/roxTs3MiEFtwEnMaPMV8+fOWVsCezqOQN1WNe8TaVdLNe DMuj+BUEFrl5Yky3CviDr7U0AFNjkntZeH7SF0wLptyDbnU+rq9TG97CE9sIA6L0iwNt 8b/mvsbHherQp25Ze+df1/AL9wJqjzU1gEkIE= 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=1gorWaBOTDzwkFhAp9D2nVno0BUb+tV20gLZenZj/T4=; b=At5Pj1ipsyVVaBokPEMpeE/4lt0KP41DZX0kOgvW8QydMbyF8pFx8PmMwzwlM7TdKW VIvh018mVUbI/Q9n3y6zQ51ReIvzEGoeli1QA2HqH9j+yR5jdNocdepGHn3eZ9DKqNru axA46jnlHD9FsTGqQaDX1+JyBTZlHhNvaoRL/RxhDaJbQVOU1JJz1I/boPOADNRKkGYA b3NUptfXaFYyp/UI/9A0uYtcyJ4sEn4/nJ7ZfMMLpmmuPcm9pwJvu+jXh3BMUMrurM/E 7LedLkvLc+K6LhahAeOdHAOmetttybfJZRBlcH8fMJQYX49eStrkHclPEhGFNwj2tR5k Pvfg== X-Gm-Message-State: AOAM532J4/DGK8JJ8NWIYk5nucwEruYVxOwS/haWCvMe4lvSnJCWLqJ2 1Ge6Hzr8wvC6bg10HjQKYDJc8jUvJVw= X-Received: by 2002:a05:651c:1034:: with SMTP id w20mr677764ljm.382.1595461372717; Wed, 22 Jul 2020 16:42:52 -0700 (PDT) Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com. [209.85.208.174]) by smtp.gmail.com with ESMTPSA id d21sm1152102ljo.85.2020.07.22.16.42.50 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Jul 2020 16:42:51 -0700 (PDT) Received: by mail-lj1-f174.google.com with SMTP id h22so4388940lji.9 for ; Wed, 22 Jul 2020 16:42:50 -0700 (PDT) X-Received: by 2002:a2e:991:: with SMTP id 139mr664554ljj.314.1595461370291; Wed, 22 Jul 2020 16:42:50 -0700 (PDT) MIME-Version: 1.0 References: <20200721063258.17140-1-mhocko@kernel.org> In-Reply-To: From: Linus Torvalds Date: Wed, 22 Jul 2020 16:42:34 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH] mm: silence soft lockups from unlock_page To: Hugh Dickins , Oleg Nesterov Cc: Michal Hocko , Linux-MM , LKML , Andrew Morton , Tim Chen , Michal Hocko Content-Type: multipart/mixed; boundary="0000000000003af25505ab104cfa" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --0000000000003af25505ab104cfa Content-Type: text/plain; charset="UTF-8" On Wed, Jul 22, 2020 at 3:10 PM Linus Torvalds wrote: > > > + 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. Actually, I think the right thing to do is to just say "we should never add ourselves back to the list". We have three cases: - DROP: we'll never loop - SHARED: we'll break if we see the bit clear - so if we're no longer on the list, we should break out - EXCLUSIVE: we should remain on the list until we get the lock. and we should just handle these three cases in the wakeup function instead, I feel. And then to make it fair to people, let's just always add things to the head of the queue, whether exclusive or not. AND NEVER RE-QUEUE. IOW, something like the attached patch. NOTE NOTE NOTE! This is both somewhat subtle code, and ENTIRELY UNTESTED. But it actually fixes the bug mentioned a few weeks ago, it makes the code simpler in one sense, and it avoids the whole re-queueuing thing. It removes all the "is the page locked" testing from the actual wait loop, and replaces it with "is the wait queue entry still on the list" instead. Comments? Oleg, this should fix the race you talked about too. Note that this patch really is meant as a RFC, and "something like this". It builds. I tried to think it through. But it might have some obvious thinko that means that it really really doesn't work. Linus --0000000000003af25505ab104cfa Content-Type: application/octet-stream; name=patch Content-Disposition: attachment; filename=patch Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_kcy0hit60 IG1tL2ZpbGVtYXAuYyB8IDE1NyArKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysr KysrKystLS0tLS0tLS0tLS0tLS0tLQogMSBmaWxlIGNoYW5nZWQsIDExMSBpbnNlcnRpb25zKCsp LCA0NiBkZWxldGlvbnMoLSkKCmRpZmYgLS1naXQgYS9tbS9maWxlbWFwLmMgYi9tbS9maWxlbWFw LmMKaW5kZXggMzg1NzU5YzRjZTRiLi5lNDQ4NzNkYTVkMTkgMTAwNjQ0Ci0tLSBhL21tL2ZpbGVt YXAuYworKysgYi9tbS9maWxlbWFwLmMKQEAgLTEwMDAsOCArMTAwMCwxNiBAQCBzdHJ1Y3Qgd2Fp dF9wYWdlX3F1ZXVlIHsKIAl3YWl0X3F1ZXVlX2VudHJ5X3Qgd2FpdDsKIH07CiAKKy8qCisgKiBX YWtlIGZ1bmN0aW9uIHJldHVybiB2YWx1ZToKKyAqICAtMTogInN0b3AiCisgKiAgIDA6ICJnbyBv biIuCisgKiAgIDE6IHdlIGhhbmRsZWQgYW4gZXhjbHVzaXZlIGNhc2UKKyAqLwogc3RhdGljIGlu dCB3YWtlX3BhZ2VfZnVuY3Rpb24od2FpdF9xdWV1ZV9lbnRyeV90ICp3YWl0LCB1bnNpZ25lZCBt b2RlLCBpbnQgc3luYywgdm9pZCAqYXJnKQogeworCWludCByZXQ7CisJc3RydWN0IHRhc2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