Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp126099pxj; Wed, 26 May 2021 18:08:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8jrtMQ+TWi0vSP7UDrM21MWGsXExQfg9/qwJicEnFCGEtpFw0Wwxcl9GgCPxuXhh0dbb1 X-Received: by 2002:a6b:690c:: with SMTP id e12mr844417ioc.69.1622077687237; Wed, 26 May 2021 18:08:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622077687; cv=none; d=google.com; s=arc-20160816; b=qNKPGW/WQ3mVFXxRED/cQIrycbNoDkbrIe/IxqoBKrzz4GEcPqVzUnL3jchQeUjTsa xUODFWLAtG8iQCC1XKd+0a/EuSCcgSF1glkkAvSeje9m8KHMOsk6y4ygYlP3+/luwYWu uA0oyz3WyqPdNSSGB1ZfezOs4MswoUPsyNFeOUezE72Sb9CVruUIkRusbWDUOxUVrFVm WDUwligI/blSH5hU5lfAaeOR92Lvu8obK8JKwWZloJNMEUlS3HVkXbuNWRWgJ/BO3fQA /L7GpEh7sQFq9yHcMqm0yWnvA+L5vAWVsNgAeff6DCwYIELFy2Iir14Dbq4rGVMZFLOU VCiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=gyEju9+TLZeZG3bChNms/qB8ZByEtpBtdp/UD5bEjms=; b=BxsAbg8d3DWsQxEKPzVSQmmu9rgUpDCdwAW95yAqV8ylE1Q9LXymsuZPsETqjW/Sl5 JWGJwmwWttW9CvletYDwuHn475ML2vbxkh6JQJCAZz8UM0aWe0t5fMDCpPwnEM3zNLJt S4WiwpaSjmaJb4a2LVrr//4dEufrDNIZoNWlYVgIcJiLA5kKl4HwC4DDNKbSMti01Z0k +boGxvNfwHNIzyqC+2klH9DEgE/VTg1il+Psceo/AW9tt0gL/S2skeLJPoiVkrQNTXXk YjEYFJJepalXd4ILNyRvlNqdu47GJe+w3ROdlXhjGPyzVaCmElZ55AWUbP8NLp7OtaxK KJNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=shqvBt5S; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b9si706503ior.14.2021.05.26.18.07.51; Wed, 26 May 2021 18:08:07 -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=@google.com header.s=20161025 header.b=shqvBt5S; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233785AbhEZWua (ORCPT + 99 others); Wed, 26 May 2021 18:50:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229799AbhEZWua (ORCPT ); Wed, 26 May 2021 18:50:30 -0400 Received: from mail-ot1-x333.google.com (mail-ot1-x333.google.com [IPv6:2607:f8b0:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F8E9C061574 for ; Wed, 26 May 2021 15:48:57 -0700 (PDT) Received: by mail-ot1-x333.google.com with SMTP id 69-20020a9d0a4b0000b02902ed42f141e1so2607692otg.2 for ; Wed, 26 May 2021 15:48:57 -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=gyEju9+TLZeZG3bChNms/qB8ZByEtpBtdp/UD5bEjms=; b=shqvBt5Sb2Ed6AByKZFJbS/YbN1VytHSP2SUnnk6+LSKCi9dmvX7FPbiNmM+g0tWjm APBVu9ZANOLb81FOOxUxxC+uyCRO0bvnQEp3Qmkg1nLinEz5YKypgiy5eLtwtI7FbQrm ZW4ZALCWmzvHI7qeogV4u93jCk+a8VpIpE25ejPVAFo1gUERnsPFweUtHfg8k4ggktTR 0JHkXvqReQS10W/AcISkgmaZ0oky8376Uil/p5Bg/QJIaqdLrihKNQcCSz65FuVu/R9z KjGnCk3BdJ5hWCDdeIplfwhrtr8C9C0Fe6vs2TgY/LyT6dFO5iJF4P3V8ODNL3Z5g07N MRig== 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=gyEju9+TLZeZG3bChNms/qB8ZByEtpBtdp/UD5bEjms=; b=Se8oJLrAPjTGuY+VnmYv6Xt7LfUbQrbMkzRDqKB5oF6M+WArJ1T1ZftY+GmjFR6axu CkM9ACY7BrfAyYA8QX2JQ47r0s6SIcjTJM5eR+8+v34HtflpEpY4St9As7RJgUelt2pa 28EFPo2mN8jnfzMef/w5qPIwq6NV48jnX2bgYsDKYrDbwWRrUzWfaupMeUj8YMr0S7Pp TF35QKqTptXO6mi6MPVP3yYw7412zJlyKORAROeBpxgkkZgvyNzqlxvPg/MMP5ElAndc iqs+T6ruXGPLOyzkv+wngWss8ancxVjtUclNFP90ZjQoz8E6MVCFUKAD6K+PVT80Fm49 IiAw== X-Gm-Message-State: AOAM531gia1MvbeeAlvPkD2rU3LRTaepZgJQwOQweOYgY9AHbf2JgX0x A21cWLBgNgORClXFqcMaDtuI7A== X-Received: by 2002:a9d:57cd:: with SMTP id q13mr450099oti.23.1622069336275; Wed, 26 May 2021 15:48:56 -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 m66sm133009oia.28.2021.05.26.15.48.55 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Wed, 26 May 2021 15:48:55 -0700 (PDT) Date: Wed, 26 May 2021 15:48:42 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Yang Shi cc: Hugh Dickins , Zi Yan , "Kirill A. Shutemov" , =?UTF-8?Q?HORIGUCHI_NAOYA=28=E5=A0=80=E5=8F=A3_=E7=9B=B4=E4=B9=9F=29?= , Wang Yugui , Andrew Morton , Linux MM , Linux Kernel Mailing List Subject: Re: [v3 PATCH 2/2] mm: thp: check page_mapped instead of page_mapcount for split In-Reply-To: Message-ID: References: <20210525162145.3510-1-shy828301@gmail.com> <20210525162145.3510-2-shy828301@gmail.com> 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 Wed, 26 May 2021, Yang Shi wrote: > On Tue, May 25, 2021 at 4:58 PM Hugh Dickins wrote: > > On Tue, 25 May 2021, Yang Shi wrote: > > > > > > We should be able to make dump_page() print total mapcount, right? The > > > dump_page() should be just called in some error paths so taking some > > > extra overhead to dump more information seems harmless, or am I > > > missing something? Of course, this can be done in a separate patch. > > > > I didn't want to ask that of you, but yes, if you're willing to add > > total_mapcount() into dump_page(), I think that would be ideal; and > > could be helpful for other cases too. > > > > Looking through total_mapcount(), I think it's safe to call from > > dump_page() - I always worry about extending crash info with > > something that depends on a maybe-corrupted pointer which would > > generate a further crash and either recurse or truncate the output - > > but please check that carefully. > > Yes, it is possible. If the THP is being split, some VM_BUG_* might be > triggered if total_mapcount() is called. But it is still feasible to > print total mapcount as long as we implement a more robust version for > dump_page(). Oh dear. I think the very last thing the kernel needs is yet another subtly different variant of *mapcount*(). Do you have a specific VM_BUG_* in mind there? Of course there's the VM_BUG_ON_PAGE(PageTail) at the start of it, and you'd want to print total_mapcount(head) to avoid that one. Looks like __dump_page() is already careful about "head", checking whether "page" is within the expected bounds. Of course, once we're in serious VM_WARN territory, there might be races which could flip fields midway: PageTail set by the time it reaches total_mapcount()? Narrow the race (rather like it does with PageSlab) by testing PageTail immediately before calling total_mapcount(head)? Hugh