From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B781CC433F5 for ; Thu, 3 Mar 2022 17:26:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 061418D0002; Thu, 3 Mar 2022 12:26:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F2C1D8D0001; Thu, 3 Mar 2022 12:26:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF3A88D0002; Thu, 3 Mar 2022 12:26:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id CCF278D0001 for ; Thu, 3 Mar 2022 12:26:01 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 89C61609A8 for ; Thu, 3 Mar 2022 17:26:01 +0000 (UTC) X-FDA: 79203752922.14.D90E38A Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) by imf18.hostedemail.com (Postfix) with ESMTP id 22A761C0006 for ; Thu, 3 Mar 2022 17:26:00 +0000 (UTC) Received: by mail-qk1-f172.google.com with SMTP id q4so4408534qki.11 for ; Thu, 03 Mar 2022 09:26:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:in-reply-to:message-id:references :mime-version; bh=HpUtMT59V1Dnqp2zw86tWtEA5X/jod13ModO/+p9Deo=; b=jjawInHuhXlrYKywMUQ6u85Mb3wkFgN3bCEJteCcFDNQ5uE5FGq0UjCO0L1TGWL8ab V9GlBewr1A8gUJa1B1B05NANwOqSfQcI30W4w/k6lpJTCutjJWRKkinSmDR5wt1FO4yi iVpikjy4C9Gwl9rif/sa+Pg8X+ItbNh2d/Pk0NS8o0natuNtomeGNQWH+DrPzSsDr5Pg iZRJXppysKoSPlVicQOh4xbzWB+Ajp+xq9/Bwvq7XTAk7elO+CFXC7XTH2tVtRCn7jJE P37MCW0SSa1kjzlO7mU0/alFefExPamQZxOwDxq/qd2Ulgs6Bip+x63MjdphEphkcdTS vZfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:mime-version; bh=HpUtMT59V1Dnqp2zw86tWtEA5X/jod13ModO/+p9Deo=; b=TORN08WwQMiq5aRKBDEStxqivMuuTWD9ntjE5ggmHhgKPiwEe/aQSzhgYaGKtSsKd0 aTHx8hQ8RsBv2GiNtFkGSVz4KKG2H57ZSYoZlycXL/EGWMbTKnNWNFBum3Z4IISM2Jme HMRAocAWCtP09zdyVNSA2+BRMO8nySUZJ1SiG0pJagJMxcpWOF7oitNn1HtlDLKJpggf 9BTaaMNYbT+Wwe9XtId3Lfymx9HzJn9oo2sJeLguM/Q3zOYE8UnA5ZETfBNMh8TL55fB MGMdppO9cFzdwfAXDVh0whMuTZonbz2eFiK2o+uLLfGL3Xu1niN7KDcYKLKM/PPreK5B 2c+g== X-Gm-Message-State: AOAM531hyi8kE1eccJDX7I/jL14DV+/K4Osc5NqnHPG97KmBOmxXs9hU OjhroSE+KUVMXNfVObSjhM0abA== X-Google-Smtp-Source: ABdhPJzqju+8pmjZ5eHUzN8w+ZiB6sEbK9gZCNHSaTxhq8obDD2oNU51ROCDYUqOHHK+KP/bGnvf2w== X-Received: by 2002:a05:620a:1a08:b0:648:ac5c:37eb with SMTP id bk8-20020a05620a1a0800b00648ac5c37ebmr163288qkb.49.1646328360132; Thu, 03 Mar 2022 09:26:00 -0800 (PST) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id d77-20020ae9ef50000000b00649555ce936sm1331249qkg.83.2022.03.03.09.25.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 09:25:59 -0800 (PST) Date: Thu, 3 Mar 2022 09:25:47 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@ripple.anvils To: Matthew Wilcox cc: Hugh Dickins , Andrew Morton , Vlastimil Babka , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH mmotm] mm/munlock: mlock_vma_folio() check against VM_SPECIAL In-Reply-To: Message-ID: <39f9e61b-c66c-a741-5118-997a48dd440@google.com> References: <9b95d366-1719-f8e2-a5a3-429f9e808288@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 22A761C0006 X-Stat-Signature: p7he8tdk9qbojqinycknn1oaj19ytf16 Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=jjawInHu; spf=pass (imf18.hostedemail.com: domain of hughd@google.com designates 209.85.222.172 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com X-HE-Tag: 1646328360-307851 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, 3 Mar 2022, Matthew Wilcox wrote: > On Wed, Mar 02, 2022 at 05:35:30PM -0800, Hugh Dickins wrote: > > Although mmap_region() and mlock_fixup() take care that VM_LOCKED > > is never left set on a VM_SPECIAL vma, there is an interval while > > file->f_op->mmap() is using vm_insert_page(s), when VM_LOCKED may > > still be set while VM_SPECIAL bits are added: so mlock_vma_folio() > > should ignore VM_LOCKED while any VM_SPECIAL bits are set. > > > > This showed up as a "Bad page" still mlocked, when vfree()ing pages > > which had been vm_inserted by remap_vmalloc_range_partial(): while > > release_pages() and __page_cache_release(), and so put_page(), catch > > pages still mlocked when freeing (and clear_page_mlock() caught them > > when unmapping), the vfree() path is unprepared for them: fix it? > > but these pages should not have been mlocked in the first place. > > > > I assume that an mlockall(MCL_FUTURE) had been done in the past; or > > maybe the user got to specify MAP_LOCKED on a vmalloc'ing driver mmap. > > > > Signed-off-by: Hugh Dickins > > --- > > Diffed against top of next-20220301 or mmotm 2022-02-28-14-45. > > This patch really belongs as a fix to the mm/munlock series in > > Matthew's tree, so he might like to take it in there (but the patch > > here is the foliated version, so easiest to place it after foliation). > > It looks like it fixes "mm/munlock: mlock_pte_range() when mlocking or > munlocking", so I'll fold it into that patch? No and yes. That's great if you're prepared to move it back before the foliation. I think that just involves editing every "folio" to "page", including in the title - I very nearly sent it out with mlock_vma_page() in title. But I would prefer it to remain as a separate fix at the end of the mm/munlock series: this case is too unusual, and only a "Bad page", to mess with bisection prospects; and it's addressing an entirely different issue from what the "mlock_pte_range()..." is dealing with. Each of them needs its own explanation. So I would prefer it as a separate fix about "page"s, on top of the mm/munlock series, and you then adjust your foliation commit accordingly. Thank you: this is what I really wanted, but was afraid to ask of you (and of course, other fixes may turn out to be required, too late to adjust across the page<->folio barrier in this way: so it's nice to be able to do it this way, but rather beyond the call of duty). Hugh