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 A48CAC87FD2 for ; Thu, 29 Aug 2024 18:49:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 243BC6B00C2; Thu, 29 Aug 2024 14:49:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1F40F6B00C4; Thu, 29 Aug 2024 14:49:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 06D996B00C5; Thu, 29 Aug 2024 14:49:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id D6A656B00C2 for ; Thu, 29 Aug 2024 14:49:31 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 8EB33C01D5 for ; Thu, 29 Aug 2024 18:49:31 +0000 (UTC) X-FDA: 82506171342.01.EA045A3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf13.hostedemail.com (Postfix) with ESMTP id 647D420014 for ; Thu, 29 Aug 2024 18:49:29 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=elyTv0ib; spf=pass (imf13.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724957299; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=LFCmp1yoRO+i1Fo2RkC+TtCKMiDRvz30b3MajzW3nrI=; b=xjjupzj4GITOOKM0J5RmPXok72Q0gtdP9CnEmspLn/90q3K5ZYm3bSvgwOG4JeWZ6itatb bnen7qqLHZd2b4aVgo7H4n/M2Ji1Lo08VCpSvafdvwDq2hL2qMIbPi49CV6rHiaGJQT5G8 Sa755tB3jE0qLMbQFxcXINlrLO5t0w0= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=elyTv0ib; spf=pass (imf13.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724957299; a=rsa-sha256; cv=none; b=KRWccM3tBI31Dhr5prpvXwqL2uk9z7g03nHzwvqseynunnJEUl8C015soH3ZmlgXqgbqUi GVYWdTiMstVSXUhTeI45hp2VRabFiuqqml9pI47Pqk/twALZhNnNaHM0N74cy+3zI7EHBP /cRl/sw9xFb/HuW3I+cTOLiuuri2VAE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724957368; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=LFCmp1yoRO+i1Fo2RkC+TtCKMiDRvz30b3MajzW3nrI=; b=elyTv0ibn0UW4h8tlJ5uwGUEp26BFdq+bbhmBPK666MmP+oga9p3fYnMxA/6CVsjCpDo3A oGB2BZn7+Ce5O4FivDkO78GTS361S9OlN0ZjJTMGdwVQHfxUmjuSuQ6jwUaWtTY1LurBXw z8Sf5buNcj1JbCy4x6f1RAJwzI6lsIc= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-29-ekM-ECFoN6-yvTYwqpJMnQ-1; Thu, 29 Aug 2024 14:49:27 -0400 X-MC-Unique: ekM-ECFoN6-yvTYwqpJMnQ-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-7a80599c404so141256985a.3 for ; Thu, 29 Aug 2024 11:49:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724957367; x=1725562167; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=LFCmp1yoRO+i1Fo2RkC+TtCKMiDRvz30b3MajzW3nrI=; b=PKf5YvMU26Rhx8hYMOlI6sp/tjYZSONfRSfEFu+bdiKOudawxNR8Wvl5zJmArYVWzM o7yhtV2RexkMTqcvBSqxufJgpqHsBtmF4PUe3OifZ3lhaH5m2Psg3Wflft1QH756F7Mj g3b5mH1OQ8JInH7a8WD/iiXL/lJkZoVLuS2SG86mLqKrDu+t8yRzwuWXBFlGteFB/nzj fM643L22xtjhy4ihfGhKLOFUXCYBdvX1yATrJf1rLsJesbmcCVKohVwHHMraMYdhT0lY banFIDRybJPYnZ7hq6cNIcg9vQgrAERm5NHn+T25myMzWbndfWAU1nV+owI/ezarFilG CiiA== X-Forwarded-Encrypted: i=1; AJvYcCXltHuFmiKAfNAQTkd+prxkb2TI9WxWGd4mhuXIi6Lu8KN3RZgSwWczyqTAb5r6ln8HHg12KaqFfw==@kvack.org X-Gm-Message-State: AOJu0YyVhclvqUsw8VRVEQpl58WyT7/T6z3ON120Lzduu+Ax963+KNyk RIyuhZPtqNnr3ws9rIhExWYNNmetAXQptiv3NVt4pQsIQon1tsf+VKYOQoljhfSoDMYXea1Rw+5 JGrHgX+ohaL5aMppWE4/g/ZjfuF1ahWmXhPBbdyZ4q6AB5BPC X-Received: by 2002:a05:620a:2698:b0:79f:8f3:6ad4 with SMTP id af79cd13be357-7a804189d7emr400080285a.1.1724957366858; Thu, 29 Aug 2024 11:49:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGCqY9sQY/plh+UMSdlovT6VfMPD3RnFHECf4IOnU0YGP0F/YZ2eWEcEkgRO7YJ9NGFLEjd+Q== X-Received: by 2002:a05:620a:2698:b0:79f:8f3:6ad4 with SMTP id af79cd13be357-7a804189d7emr400076685a.1.1724957366521; Thu, 29 Aug 2024 11:49:26 -0700 (PDT) Received: from x1n (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a806bfb8a1sm75924485a.5.2024.08.29.11.49.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 11:49:26 -0700 (PDT) Date: Thu, 29 Aug 2024 14:49:23 -0400 From: Peter Xu To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Gavin Shan , Catalin Marinas , x86@kernel.org, Ingo Molnar , Andrew Morton , Paolo Bonzini , Dave Hansen , Thomas Gleixner , Alistair Popple , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sean Christopherson , Oscar Salvador , Jason Gunthorpe , Borislav Petkov , Zi Yan , Axel Rasmussen , Yan Zhao , Will Deacon , Kefeng Wang , Alex Williamson Subject: Re: [PATCH v2 06/19] mm/pagewalk: Check pfnmap for folio_walk_start() Message-ID: References: <20240826204353.2228736-1-peterx@redhat.com> <20240826204353.2228736-7-peterx@redhat.com> <9f9d7e96-b135-4830-b528-37418ae7bbfd@redhat.com> MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Stat-Signature: 7uios6g53rbwycr4ik5kfqd4tkz31g6b X-Rspam-User: X-Rspamd-Queue-Id: 647D420014 X-Rspamd-Server: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kctyKCvMgaph58HeTDYr+67Fvp7eIEg/xrvhUhkaBmE4sACqrcnGg6ufwSskSj/dEbfO85SN+4Ml+hVwXXIpo72pjgJ2YY87VFxZ100tN3J5sUOrDlMAw3Ebls4SBw+51Ui9PpxuMCqbp1o/k808Ym7WAJDiFIPxoqFjEyNglHZLibbldezWtOFi34SGGvwEb/cDelcFrAACRApDUTUp0EhGdPmpeGSwlbtH67DqPSz2egnOv8dc2P4DB6hR4hVbsgNKjn5pWCDqX/FZ6tvz5qzw0L0asEDMFI6gkkLluZBLA5WneHIx/9dG96ZBKOcrLHHGjnJze9BtiXiIbinMc8GioJpfUrB7Gw9ZTkur1qDWmdxgNG25+NeLwA74AapqqDf+rMPRAVpQhXgEUbPLmxk4Dd5Xh 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: List-Subscribe: List-Unsubscribe: On Thu, Aug 29, 2024 at 05:10:15PM +0200, David Hildenbrand wrote: > > > > > > > > If you prefer vm_normal_page_pud() to be defined and check pud_special() > > > > there, I can do that. But again, I don't yet see how that can make a > > > > functional difference considering the so far very limited usage of the > > > > special bit, and wonder whether we can do that on top when it became > > > > necessary (and when we start to have functional requirement of such). > > > > > > I hope my explanation why pte_special() even exists and how it is used makes > > > it clearer. > > > > > > It's not that much code to handle it like pte_special(), really. I don't > > > expect you to teach GUP-slow about vm_normal_page() etc. > > > > One thing I can do here is I move the pmd_special() check into the existing > > vm_normal_page_pmd(), then it'll be a fixup on top of this patch: > > > > ===8<=== > > diff --git a/mm/memory.c b/mm/memory.c > > index 288f81a8698e..42674c0748cb 100644 > > --- a/mm/memory.c > > +++ b/mm/memory.c > > @@ -672,11 +672,10 @@ struct page *vm_normal_page_pmd(struct vm_area_struct *vma, unsigned long addr, > > { > > unsigned long pfn = pmd_pfn(pmd); > > - /* > > - * There is no pmd_special() but there may be special pmds, e.g. > > - * in a direct-access (dax) mapping, so let's just replicate the > > - * !CONFIG_ARCH_HAS_PTE_SPECIAL case from vm_normal_page() here. > > - */ > > + /* Currently it's only used for huge pfnmaps */ > > + if (unlikely(pmd_special(pmd))) > > + return NULL; > > > Better. > > I'd appreciate a vm_normal_page_pud(), but I guess I have to be the one > cleaning up the mess after you. I'll prepare either a fixup patch for above, or repost if there're more changes. Again, please leave explicit comment please. As I mentioned, to me vm_normal_page_pud() currently should only contain pud_special() check, as most of the things in pmd/pte don't seem to apply. I don't feel strongly to add that wrapper yet in this case, but if you can elaborate what you're suggesting otherwise, it may help me to understand what you're looking for, then I can try to address them. Or if you prefer some cleanup patch by yourself, please go ahead. -- Peter Xu