Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2744015ybc; Wed, 20 Nov 2019 20:16:08 -0800 (PST) X-Google-Smtp-Source: APXvYqyKeuzvWiOEeaMFhEsSo2WfS9ZMaJ9t6BL9YNyQU9wA6Catn3Tm+cOUaN44PUNpaU+iayOi X-Received: by 2002:a17:907:20b8:: with SMTP id pw24mr10429202ejb.28.1574309768603; Wed, 20 Nov 2019 20:16:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574309768; cv=none; d=google.com; s=arc-20160816; b=Fxrwfme8kCdS/53+wNBmMUvJrMcSMqYyA7ZqM+BwSlZ9avH4KuORpyA+3OEZ479/4M DZqV4JJkO/gVgkTzOCwYHTxbABjlESG+bkqQGDcFmB2410Vu0iNCeSy7lymOFgF15wNr P1zRvKlx+YnzHLUtfcBguXgZiE/2L+uo02prKDwOay2/aRGwj3aP1TmVjA0toQ/y9m5u 6bPU2yCB9nfrEqajyFabwZMbnokLzKAy1KzLill+8hnxL3aQWCdw3DtPxmrW+5deT2rZ sQFPa11AF4RhndQBb/b7jcrQw1yIlI/8SeCQRTxxRDlurDwgWg9Px/nmrSthTfh/cQ1j 0vRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=kP2wggYyMK9//uGeO+OrprwkC14o85isnyjfCuB8bk8=; b=PNKXWIEkOgdM6efB7kjpiUWJ6hIHJYcq//VCcSGBlKA4FoEuOOQ1l/yXYWuEbwdxKW r3ngPq91O8jjCSwxKB/Ja07/a1xVBQFDMXRq4jVsHt0CUjbz8UHBqPz+MgkLtdj9+oqi RqQphp1r+4mxF/RKrHKmXPlbNNbd0bZ4IDPTaNOQqW7FIeqGE9SHQFL3lqChwP1KfpRu eU7SpevvtDOmH3ImnbKA9LwtfWEXjyDcxehvjyHsUVXbd43txjhHi1iSEZ5LKX5TrHSp keZRNIBpC+0mDR1gB7ZKTD/dETez6+C4hU7S4KvuLtxJYueInp91poJbeba7p2G2m0g3 rZWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=L5mfgtqz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g11si822399ejx.212.2019.11.20.20.15.44; Wed, 20 Nov 2019 20:16:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=L5mfgtqz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726083AbfKUEM1 (ORCPT + 99 others); Wed, 20 Nov 2019 23:12:27 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:41676 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725819AbfKUEM0 (ORCPT ); Wed, 20 Nov 2019 23:12:26 -0500 Received: by mail-pg1-f194.google.com with SMTP id 207so892554pge.8 for ; Wed, 20 Nov 2019 20:12:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=kP2wggYyMK9//uGeO+OrprwkC14o85isnyjfCuB8bk8=; b=L5mfgtqzQKkH1DybloeEYuTP5c6VICzluWnLCN4IaAZfFfme0kZCK724NmmPcAKECy XJ5kCClp1FXFbrX1552Bxd/01IjOuuxDOF2CDfgWiMuBrErhzJzd03+xtkavIr9yydkY P99hfYv0/f5TshZvfjhoyj97aVtJPpINI7mXE5H7io9DmrlEGH75n3TdY6p2332rvO/1 H9FsqCnyPJn3tkfdDn2LpflOoFZktQQLkOQW16WGZlFK9HY+DIQlFCqHLLnK2LzwbH5r GbmqATrc7dB8axOR/Pu2zCMguH1+ycWNPGckw+dof/kmHyhdB4lD5nWf2ljfUr9Pb8l+ ePGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=kP2wggYyMK9//uGeO+OrprwkC14o85isnyjfCuB8bk8=; b=hr8qwrUhVB5d/hK9mMlsRO1jpqjWOVodZv6vWkqR16VRB2c2GB+x3vydGQcPckb0rl 61tKiFRi9pXrJ2fKPln1Ox92HuTV+3fKYHYutESTJ6j35YOHlgogLslfywLBnrDaAVz/ 7fo37TZ3BeUzT5zPyXF0Ys4uS5VwrtuikxAlzO97yLt+9GF4ppzW1Cbiw8hFxHOvvM4M IrioDfZa0bgfEpthHTKMPml2UjPhOY2c5L99kAytUVghLqKdAlupcSt/7AoZN+HL69b1 KSUApSvmYqSfr7DpWBS4vHAwL11b1Ie/4Lmb91uQo1Z1RaXJrU+/XCpjv1GmnV3Ld4XR ajBQ== X-Gm-Message-State: APjAAAVQz4jZp5az3525MuWcqwZIVaIgM+ik0qakVybPOLSf515oAWNx ZxY9N2K2XgHodJ5SQsQ0ZtuyWg== X-Received: by 2002:a63:e54f:: with SMTP id z15mr7289785pgj.453.1574309545267; Wed, 20 Nov 2019 20:12:25 -0800 (PST) Received: from [100.112.92.218] ([104.133.9.106]) by smtp.gmail.com with ESMTPSA id y26sm1036291pfo.76.2019.11.20.20.12.23 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Nov 2019 20:12:24 -0800 (PST) Date: Wed, 20 Nov 2019 20:12:13 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Andrey Ryabinin cc: Andrew Morton , Hugh Dickins , Andrea Arcangeli , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/ksm: Don't WARN if page is still mapped in remove_stable_node() In-Reply-To: <20191119131850.5675-1-aryabinin@virtuozzo.com> Message-ID: References: <20191119131850.5675-1-aryabinin@virtuozzo.com> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 19 Nov 2019, Andrey Ryabinin wrote: > It's possible to hit the WARN_ON_ONCE(page_mapped(page)) in > remove_stable_node() when it races with __mmput() and squeezes > in between ksm_exit() and exit_mmap(). > > WARNING: CPU: 0 PID: 3295 at mm/ksm.c:888 remove_stable_node+0x10c/0x150 > > Call Trace: > remove_all_stable_nodes+0x12b/0x330 > run_store+0x4ef/0x7b0 > kernfs_fop_write+0x200/0x420 > vfs_write+0x154/0x450 > ksys_write+0xf9/0x1d0 > do_syscall_64+0x99/0x510 > entry_SYSCALL_64_after_hwframe+0x49/0xbe > > Remove the warning as there is nothing scary going on. > > Fixes: cbf86cfe04a6 ("ksm: remove old stable nodes more thoroughly") > Signed-off-by: Andrey Ryabinin Thanks - Acked-by: Hugh Dickins > Cc: For removing a WARN_ON_ONCE? No, I don't think this needs to go to stable; but I won't resist if Andrew or autobot insist otherwise. > --- > mm/ksm.c | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/mm/ksm.c b/mm/ksm.c > index dbee2eb4dd05..7905934cd3ad 100644 > --- a/mm/ksm.c > +++ b/mm/ksm.c > @@ -885,13 +885,13 @@ static int remove_stable_node(struct stable_node *stable_node) > return 0; > } > > - if (WARN_ON_ONCE(page_mapped(page))) { > - /* > - * This should not happen: but if it does, just refuse to let > - * merge_across_nodes be switched - there is no need to panic. > - */ > - err = -EBUSY; > - } else { > + /* > + * Page could be still mapped if this races with __mmput() running in > + * between ksm_exit() and exit_mmap(). Just refuse to let > + * merge_across_nodes/max_page_sharing be switched. Good comment, thank you. > + */ > + err = -EBUSY; > + if (!page_mapped(page)) { > /* > * The stable node did not yet appear stale to get_ksm_page(), > * since that allows for an unmapped ksm page to be recognized > -- > 2.23.0