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 X-Spam-Level: X-Spam-Status: No, score=-14.8 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B94F5C4743C for ; Fri, 4 Jun 2021 21:53:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 98EE3613B4 for ; Fri, 4 Jun 2021 21:53:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231580AbhFDVzR (ORCPT ); Fri, 4 Jun 2021 17:55:17 -0400 Received: from mail-qk1-f176.google.com ([209.85.222.176]:46804 "EHLO mail-qk1-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229930AbhFDVzQ (ORCPT ); Fri, 4 Jun 2021 17:55:16 -0400 Received: by mail-qk1-f176.google.com with SMTP id 76so10796171qkn.13 for ; Fri, 04 Jun 2021 14:53:13 -0700 (PDT) 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=5ALgaqHb4Ps4FEwMFfNaWGSDMjcH3JF+dL8YdWEXIPU=; b=hwbq82k9vMgWFKloVlJ2XlYpNE6rWAmJsCAvCH1RcWEFw1WWNXtuikZXcPE4SzmqXw RqkKYab5vj6MNgQoLiUWDhJLjnj1C3ZcWIPXDdBytN+3zTtFjp7JRK1+RgQX7+hRXz9O RThWudmiBRFZUvFzZqZfSCsE9Gs06Z9EOqRfahuqGxCEqF7KuWt6slPLsvIga7KxRdMW JPOk37kTve0uV88/+36KtMnNHoGqRfddzQBEGUTSnjQvU6/M8BFUdX+jIzWJbKeppH+7 grmIJJu3TQDh0hQmrTpomqz4mgdGr7LWktmw5X6GkhXEdikSuoZ3jFi34e0A6NZ2z8ET C7EA== 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=5ALgaqHb4Ps4FEwMFfNaWGSDMjcH3JF+dL8YdWEXIPU=; b=o500axQlnw/7lAkHmEL+94npuxUR4vJvB1N2K5Xm2dBBsPSiVbc/JF492yySyBQ6YS kIpaZX7aylxHLHslUDtS0FMyXbNPCY6KTs1HXI3pakX0l8Yre5StlkaB/b+naGc4tFPG Aok5lza3hjee0D340+NDVXFGFhsoMJEta8xrNLvxCmfGN8EyL7gS0n6QDj5CHQvE9soi g1yY6cqRgTIZxTgSBH9Y4DqKdbaoUUE4LpL1O5IBHXcOvmtXoMQZYQz730XLK5yXaWXm Wyki4TTGeeWhzNCRbkVW2Lh5nb3sZa5Ehu7YbkfUiFNzVwKdHzgejpWZJCm1VeiGyFjD kJuQ== X-Gm-Message-State: AOAM532J8UzTTRYR0ogVGclldHBSmM3HHfyW+OoIlPXyJt6d0g8JaMfi sOXrIEL0DxUXg4L6+gGs35Hiew== X-Google-Smtp-Source: ABdhPJzcLao8TwXtuyU+4+xr5mTTOURG8is2Ws5i5yjPMOn2BcNK9veCKI7sf81F5xj4tjiIM9T+jQ== X-Received: by 2002:a37:8507:: with SMTP id h7mr6224742qkd.277.1622843532434; Fri, 04 Jun 2021 14:52:12 -0700 (PDT) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id f13sm4728423qkk.107.2021.06.04.14.52.10 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Fri, 04 Jun 2021 14:52:12 -0700 (PDT) Date: Fri, 4 Jun 2021 14:52:09 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Yang Shi cc: Hugh Dickins , Andrew Morton , "Kirill A. Shutemov" , Wang Yugui , Matthew Wilcox , Naoya Horiguchi , Alistair Popple , Ralph Campbell , Zi Yan , Miaohe Lin , Minchan Kim , Jue Wang , Peter Xu , Jan Kara , Linux MM , Linux Kernel Mailing List Subject: Re: [PATCH 1/7] mm/thp: fix __split_huge_pmd_locked() on shmem migration entry In-Reply-To: Message-ID: References: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 4 Jun 2021, Yang Shi wrote: > On Thu, Jun 3, 2021 at 7:23 PM Hugh Dickins wrote: > > On Thu, 3 Jun 2021, Yang Shi wrote: > > > On Tue, Jun 1, 2021 at 2:05 PM Hugh Dickins wrote: > > > > The point here (see commit message above) is that some unrelated pmd > > migration entry could pass the is_huge_zero_pmd() test, which rushes > > off to use pmd_page() without even checking pmd_present() first. And > > most of its users have, one way or another, checked pmd_present() first; > > but this place and a couple of others had not. > > Thanks for the elaboration. Wondering whether we'd better add some > comments in the code? Someone may submit a fix patch by visual > inspection in the future due to missing these points. I don't really want to add a comment on this, there in zap_huge_pmd(): I think it would be too much of a distraction from that dense code sequence. And the comment will be more obvious in the commit message, once I split these is_huge_zero_pmd() fixes off from __split_huge_pmd_locked() as Kirill asked. But... now I think I'll scrap these parts of the patch, and instead just add a pmd_present() check into is_huge_zero_pmd() itself. pmd_present() is quick, but pmd_page() may not be: I may convert it to use a __read_only huge_pmd_pfn, or may not: I'll see how that goes. Hugh 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 X-Spam-Level: X-Spam-Status: No, score=-14.8 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E119C47082 for ; Sat, 5 Jun 2021 04:49:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1B04561422 for ; Sat, 5 Jun 2021 04:49:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1B04561422 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 482FC6B0036; Sat, 5 Jun 2021 00:49:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4333C6B006C; Sat, 5 Jun 2021 00:49:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2AD046B006E; Sat, 5 Jun 2021 00:49:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0208.hostedemail.com [216.40.44.208]) by kanga.kvack.org (Postfix) with ESMTP id EAB276B0036 for ; Sat, 5 Jun 2021 00:49:50 -0400 (EDT) Received: from smtpin36.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 8626A8248047 for ; Sat, 5 Jun 2021 04:49:50 +0000 (UTC) X-FDA: 78218442540.36.285442E Received: from mail-qt1-f174.google.com (mail-qt1-f174.google.com [209.85.160.174]) by imf26.hostedemail.com (Postfix) with ESMTP id 0C338421108F for ; Sat, 5 Jun 2021 04:49:48 +0000 (UTC) Received: by mail-qt1-f174.google.com with SMTP id l7so8657379qtk.5 for ; Fri, 04 Jun 2021 21:49:48 -0700 (PDT) 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=5ALgaqHb4Ps4FEwMFfNaWGSDMjcH3JF+dL8YdWEXIPU=; b=hwbq82k9vMgWFKloVlJ2XlYpNE6rWAmJsCAvCH1RcWEFw1WWNXtuikZXcPE4SzmqXw RqkKYab5vj6MNgQoLiUWDhJLjnj1C3ZcWIPXDdBytN+3zTtFjp7JRK1+RgQX7+hRXz9O RThWudmiBRFZUvFzZqZfSCsE9Gs06Z9EOqRfahuqGxCEqF7KuWt6slPLsvIga7KxRdMW JPOk37kTve0uV88/+36KtMnNHoGqRfddzQBEGUTSnjQvU6/M8BFUdX+jIzWJbKeppH+7 grmIJJu3TQDh0hQmrTpomqz4mgdGr7LWktmw5X6GkhXEdikSuoZ3jFi34e0A6NZ2z8ET C7EA== 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=5ALgaqHb4Ps4FEwMFfNaWGSDMjcH3JF+dL8YdWEXIPU=; b=CSH5TQk9auFNB7yBGxpVObST02qvebPWoGKodAF//3pLurY1W+rfnMVXQVb7ZynDAc LbZyGPY6Q+ZoIm+2I5f8r8Ek5SyxegpcGuwgU9TxnF4gxEtMPSjIhupGVQa27b6y7qyr UPnUfG4FtGvBXoUFW5dYlVMNaNvLUEicqKBqVJ63TH56kZCta+sSKNJ6kEDm1FBtbpxU sXGFY62mC7gEt/MufDyTsqc6yCj2gNx+s3E8IVX8g3nsRj3cRiZWaUPJK+skYPDdNGvy /k+pvkdJZnllsnXCi4Jg3FzCtqqL2YFX/BonjzKeycPi6fi2Rb8SWM8iNmYeeo0iAJ8f Q8Bw== X-Gm-Message-State: AOAM530nGSnDOMMG1hiGA19vUBlPNsaHydhdbjznm9mA8fFsJn1DCgGM /3P30oCWAnzN6YUCPVvpKB3u9k0aOtse5Q== X-Google-Smtp-Source: ABdhPJzcLao8TwXtuyU+4+xr5mTTOURG8is2Ws5i5yjPMOn2BcNK9veCKI7sf81F5xj4tjiIM9T+jQ== X-Received: by 2002:a37:8507:: with SMTP id h7mr6224742qkd.277.1622843532434; Fri, 04 Jun 2021 14:52:12 -0700 (PDT) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id f13sm4728423qkk.107.2021.06.04.14.52.10 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Fri, 04 Jun 2021 14:52:12 -0700 (PDT) Date: Fri, 4 Jun 2021 14:52:09 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Yang Shi cc: Hugh Dickins , Andrew Morton , "Kirill A. Shutemov" , Wang Yugui , Matthew Wilcox , Naoya Horiguchi , Alistair Popple , Ralph Campbell , Zi Yan , Miaohe Lin , Minchan Kim , Jue Wang , Peter Xu , Jan Kara , Linux MM , Linux Kernel Mailing List Subject: Re: [PATCH 1/7] mm/thp: fix __split_huge_pmd_locked() on shmem migration entry In-Reply-To: Message-ID: References: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=hwbq82k9; spf=pass (imf26.hostedemail.com: domain of hughd@google.com designates 209.85.160.174 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 0C338421108F X-Stat-Signature: 5he45ybo6zc78n3acfmjzzpzindtm16s X-HE-Tag: 1622868588-662382 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 Fri, 4 Jun 2021, Yang Shi wrote: > On Thu, Jun 3, 2021 at 7:23 PM Hugh Dickins wrote: > > On Thu, 3 Jun 2021, Yang Shi wrote: > > > On Tue, Jun 1, 2021 at 2:05 PM Hugh Dickins wrote: > > > > The point here (see commit message above) is that some unrelated pmd > > migration entry could pass the is_huge_zero_pmd() test, which rushes > > off to use pmd_page() without even checking pmd_present() first. And > > most of its users have, one way or another, checked pmd_present() first; > > but this place and a couple of others had not. > > Thanks for the elaboration. Wondering whether we'd better add some > comments in the code? Someone may submit a fix patch by visual > inspection in the future due to missing these points. I don't really want to add a comment on this, there in zap_huge_pmd(): I think it would be too much of a distraction from that dense code sequence. And the comment will be more obvious in the commit message, once I split these is_huge_zero_pmd() fixes off from __split_huge_pmd_locked() as Kirill asked. But... now I think I'll scrap these parts of the patch, and instead just add a pmd_present() check into is_huge_zero_pmd() itself. pmd_present() is quick, but pmd_page() may not be: I may convert it to use a __read_only huge_pmd_pfn, or may not: I'll see how that goes. Hugh