Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2557614ybh; Fri, 24 Jul 2020 16:27:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVw9KIP1H6gkAc8NuxwpveZZQLchXT86y66mX5CZ9+b/8vnVuGEpVae3Nc+Gb1ZX71W3KS X-Received: by 2002:a17:906:ce3c:: with SMTP id sd28mr10972658ejb.382.1595633261981; Fri, 24 Jul 2020 16:27:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595633261; cv=none; d=google.com; s=arc-20160816; b=qziIZLDPg6gZ6RUOT7d5hfPnlOk7RSFkT354JFhFHU+AyPsDvTZopYeaB5k7k2Sgdd duCTevddjeSLvNhyhwoBYWaoqrOwnscSob7CIOdMf67H+1hHfkqBXSNKQfiWDsxG5tOe StRVTxLKkwUqR4bQ9czLco76PjgpncOQ2m4Ewg/YGrXCVwXI+fIExTCOOaKlEAcjx3N7 /OR/DpL05goA2rEStkBopRutOwLjgHgak49m4uQm+STrEK4gs13T/moPEepqXbsK0EgG lPa1CEk16zmSky8L7sIYPyiXWARPKdBlWRcJbg3dN8G0McjpTg+EFqLJFJs13bWgFmoT qzcw== 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=FCOCmAnXTE7rgEisjzU4LDufxCROSWiZAdkgGpbkaeM=; b=n4FxbUmTWepaBi1gfohFtPvOgK2/GKBoNdlL7K+Zcmy2cGP9AxvOYepRUa5LqYlXZm pBWHJ+GuTygBOF1kOADhpE6Ty0Uv3WSnDHX16Lw0DJuGWrjDk+WH4dep1qDs2v1iFu5H sAiKpvC4V/+u3B05rYt6lVWIPRBEujVUrENpRJGcYCzVz0cAw19svcAUWUereOxhe5Mr 9mTwRqqVD7WDcf5AEQfTjgXO8KUu/97A89f0dMy9hbrtfh5OA0k59R6hHGqUYvTTst49 2BO3Vmz6MyVe3UlrSSljo0Am/OlkJ2ic2wcHnqCaEON1ll6GpGvWnhECXj923bPG6R2u 2DKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=R5+ox8+l; 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 n27si1507252eje.543.2020.07.24.16.27.19; Fri, 24 Jul 2020 16:27:41 -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=R5+ox8+l; 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 S1726701AbgGXX0S (ORCPT + 99 others); Fri, 24 Jul 2020 19:26:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726441AbgGXX0S (ORCPT ); Fri, 24 Jul 2020 19:26:18 -0400 Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B57A3C0619D3 for ; Fri, 24 Jul 2020 16:26:17 -0700 (PDT) Received: by mail-lf1-x142.google.com with SMTP id j22so146981lfm.2 for ; Fri, 24 Jul 2020 16:26:17 -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=FCOCmAnXTE7rgEisjzU4LDufxCROSWiZAdkgGpbkaeM=; b=R5+ox8+lAZ0OQvHzjQKvw5Em1qvtnp8XYSq4FZEfYpXohFMtdM6OQnV35Xq8k+QMST Wo7V9VEp8ab+ZpRs3ATwQhvpfsfV2D5tJk8BlLlVdTBcuamptMu02JvB0+2/kGbyGa6J 7m8y5cIU8WSCI9ffD6OJsVYDDSQYYB14zj3tc= 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=FCOCmAnXTE7rgEisjzU4LDufxCROSWiZAdkgGpbkaeM=; b=X27ZGOYYmPOe+KTWREdm41E/zS1ztg42/RHdGM045UY4SCgAUTEcHVEQ4rStnyKG+G FfZz4kTjqBeWTsMDwTiKLiXV60PjDtET4XymVI+pWGO9ghL2Tjp1fInEivme82Siu4wP gwyPPu9dhR7BhO+UiKYgR+QIzqt54kGztX18EbWXFLeM2fjSXgELGc9YDRyhlxAdAGdz 5AgpNgSXBomaENsOzCIyGS4xjnxudiGStaEJNWPG0+b5wg9aOlchQzyZR2FZ9xmprG8f gbaDlEM0L5C405YCaLOcdimuDUaMO34ZZqnhcdq8dbaReRIVtA9g30WVEPWIZvvfa6wt T5ng== X-Gm-Message-State: AOAM533Vow7IjZnePnXPEv81LyRxHkoBXBfoRmINznAFgGcJ3XOnRbO2 AObXtTyZSWEK29EGEcwdp9S2w8otO4E= X-Received: by 2002:a05:6512:14d:: with SMTP id m13mr6168646lfo.173.1595633175802; Fri, 24 Jul 2020 16:26:15 -0700 (PDT) Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com. [209.85.208.172]) by smtp.gmail.com with ESMTPSA id n82sm685112lfa.40.2020.07.24.16.26.14 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Jul 2020 16:26:14 -0700 (PDT) Received: by mail-lj1-f172.google.com with SMTP id q6so11580089ljp.4 for ; Fri, 24 Jul 2020 16:26:14 -0700 (PDT) X-Received: by 2002:a05:651c:1b6:: with SMTP id c22mr4677131ljn.421.1595633173620; Fri, 24 Jul 2020 16:26:13 -0700 (PDT) MIME-Version: 1.0 References: <20200723124749.GA7428@redhat.com> <20200724152424.GC17209@redhat.com> In-Reply-To: From: Linus Torvalds Date: Fri, 24 Jul 2020 16:25:56 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH] mm: silence soft lockups from unlock_page To: Oleg Nesterov Cc: Hugh Dickins , Michal Hocko , Linux-MM , LKML , Andrew Morton , Tim Chen , Michal Hocko Content-Type: multipart/mixed; boundary="00000000000081c57b05ab384cb2" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --00000000000081c57b05ab384cb2 Content-Type: text/plain; charset="UTF-8" On Fri, Jul 24, 2020 at 10:32 AM Linus Torvalds wrote: > Ok, that makes sense. Except you did it on top of the original patch > without the fix to set WQ_FLAG_WOKEN for the non-wakeup case. Hmm. I just realized that one thing we could do is to not even test the page bit for the shared case in the wakeup path. Because anybody who uses the non-exclusive "wait_on_page_locked()" or "wait_on_page_writeback()" isn't actually interested in the bit state any more at that point. All they care about is that somebody cleared it - not whether it was then re-taken again. So instead of keeping them on the list - or stopping the waitqueue walk because somebody else got the bit - we could just mark them successfully done, wake them up, and remove those entries from the list. That would be better for everybody - less pointless waiting for a new lock or writeback event, but also fewer entries on the wait queues as we get rid of them more quickly instead of walking them over and over just because somebody else re-took the page lock. Generally "wait_on_page_locked()" is used for two things - either wait for the IO to then check if it's now uptodate - throttle things that can't afford to lock the page (eg page faults that dropped the mm lock, and as such need to go through the whole restart logic, but that don't want to lock the page because it's now too late, but also the page migration things) In the first case, waiting to actually seeing the locked bit clear is pointless - the code only cared about the "wait for IO in progress" not about the lock bit itself. And that second case generally might want to retry, but doesn't want to busy-loop. And "wait_on_page_writeback()" is basically used for similar reasons (ie check if there were IO errors, but also possibly to throttle writeback traffic). Saying "stop walking, keep it on the list" seems wrong. It makes IO error handling and retries much worse, for example. So it turns out that the wakeup logic and the initial wait logic don't have so much in common after all, and there is a fundamental conceptual difference between that "check bit one last time" case, and the "we got woken up, now what" case.. End result: one final (yes, hopefully - I think I'm done) version of this patch-series. This not only makes the code cleaner (the generated code for wake_up_page() is really quite nice now), but getting rid of extra waiting might help the load that Michal reported. Because a lot of page waiting might be that non-exclusive "wait_on_page_locked()" kind, particularly in the thundering herd kind of situation where one process starts IO, and then other processes wait for it to finish. Those users don't even care if somebody else then did a "lock_page()" for some other reason (maybe for writeback). They are generally perfectly happy with a locked page, as long as it's now up-to-date. So this not only simplifies the code, it really might avoid some problems too. Linus --00000000000081c57b05ab384cb2 Content-Type: text/x-patch; charset="US-ASCII"; name="0001-mm-rewrite-wait_on_page_bit_common-logic.patch" Content-Disposition: attachment; filename="0001-mm-rewrite-wait_on_page_bit_common-logic.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_kd0us0jf0 RnJvbSAwYmNjYjYwODQxY2M1MmE5YWE2ZTljYzZiN2VmZjU5ZDE5ODNlOGZhIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBMaW51cyBUb3J2YWxkcyA8dG9ydmFsZHNAbGludXgtZm91bmRh dGlvbi5vcmc+CkRhdGU6IFRodSwgMjMgSnVsIDIwMjAgMTA6MTY6NDkgLTA3MDAKU3ViamVjdDog W1BBVENIIDEvMl0gbW06IHJld3JpdGUgd2FpdF9vbl9wYWdlX2JpdF9jb21tb24oKSBsb2dpYwoK SXQgdHVybnMgb3V0IHRoYXQgd2FpdF9vbl9wYWdlX2JpdF9jb21tb24oKSBoYWQgc2V2ZXJhbCBw cm9ibGVtcywKcmFuZ2luZyBmcm9tIGp1c3QgdW5mYWlyIGJlaGF2aW9lIGR1ZSB0byByZS1xdWV1 ZWluZyBhdCB0aGUgZW5kIG9mIHRoZQp3YWl0IHF1ZXVlIHdoZW4gcmUtdHJ5aW5nLCBhbmQgYW4g b3V0cmlnaHQgYnVn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QlyZXR1cm4gcmV0OworCXJldHVybiB3YWl0LT5mbGFncyAmIFdRX0ZMQUdfV09LRU4gPyAw IDogLUVJTlRSOwogfQogCiB2b2lkIHdhaXRfb25fcGFnZV9iaXQoc3RydWN0IHBhZ2UgKnBhZ2Us IGludCBiaXRfbnIpCi0tIAoyLjI4LjAucmMwLjMuZzFlMjVkM2E2MmYKCg== --00000000000081c57b05ab384cb2 Content-Type: text/x-patch; charset="US-ASCII"; name="0002-list-add-list_del_init_careful-to-go-with-list_empty.patch" Content-Disposition: attachment; filename="0002-list-add-list_del_init_careful-to-go-with-list_empty.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_kd0us4ic1 RnJvbSA5M2YwMjYzYjliOTUyYTFjNDQ5Y2VjNTZhNmFhZGY2MzIwZTgyMWY5IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBMaW51cyBUb3J2YWxkcyA8dG9ydmFsZHNAbGludXgtZm91bmRh dGlvbi5vcmc+CkRhdGU6IFRodSwgMjMgSnVsIDIwMjAgMTI6MzM6NDEgLTA3MDAKU3ViamVjdDog W1BBVENIIDIvMl0gbGlzdDogYWRkICJsaXN0X2RlbF9pbml0X2NhcmVmdWwoKSIgdG8gZ28gd2l0 aAogImxpc3RfZW1wdHlfY2FyZWZ1bCgpIgoKVGhhdCBnaXZlcyB1cyBvcmRlcmluZyBndWFyYW50 ZWVzIGFyb3VuZCB0aGUgcGFpci4KClNpZ25lZC1vZmYtYnk6IExpbnVzIFRvcnZhbGRzIDx0b3J2 YWxkc0BsaW51eC1mb3VuZGF0aW9uLm9yZz4KLS0tCiBpbmNsdWRlL2xpbnV4L2xpc3QuaCB8IDIw ICsrKysrKysrKysrKysrKysrKystCiBrZXJuZWwvc2NoZWQvd2FpdC5jICB8ICAyICstCiBtbS9m aWxlbWFwLmMgICAgICAgICB8ICA3ICstLS0tLS0KIDMgZmlsZXMgY2hhbmdlZCwgMjEgaW5zZXJ0 aW9ucygrKSw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