Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp2984608rdb; Wed, 15 Nov 2023 17:29:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IHMBVoKFMoESJIJfeThtJcvynvCYMfwdQxTbK0/0Aiyzr/4+P3GDifhj5rndFPvxjYDb23f X-Received: by 2002:a05:6359:1a4c:b0:16b:f91b:3cef with SMTP id ru12-20020a0563591a4c00b0016bf91b3cefmr5318806rwb.31.1700098174121; Wed, 15 Nov 2023 17:29:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700098174; cv=none; d=google.com; s=arc-20160816; b=JfpPCTA4fSJaotlmidgFn7CYvz8ofwn0qlpoP9r+4VxziDJtfLxConEkg44IYRPyQH VrVKG7N/dheDokyUGXQchAgAmFfIu7Pzryblk1PCq9zGx3zZoQX6GJ1TQQ+9J1Y9uZxP aDrFcLCqw7trUTmXpolMiTVoq3veKCueQwLVIAQM3wARLMVLEZznebOAhuybeSvOCydu zWcqhyh3tk6H8pW0k84aDx+W90TtKSbpj2TZW/ex31aCygKbKCDOtMr3kG4aCrijKbOj 02HdbeA2a631gOue+lpf3cq6D6+zGH4XO/Xw2yxxYR2I2e7ypXamWK31RqsQFqXuicLN QVwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Rr9/qVNLgFGWDGzcAqjV00T9t0NzgxXDD6w387jcEYI=; fh=o+FJD7UTEFgAOwGBZppViFyhRpBzPGRfoO/6xzRNnMs=; b=Z2ugLTPJ24aif2ah0MgmfTqF/dsiaHI2SrcoSkcBv3AHU3VUOwNAgMQocwWnX41+ib SXnX0Y82wbk8wSRf1X01u/UZpo5Fk/4o8Bjwxt4YL6eQTCqnDs66zQc3PpktO7QxGx/s V9Ct4rkMIq5ahscUm2/sUxbbM7kZSqN5rshN8wykqLA8xbUfZhuDPu0SeVX8ejiVGA9e RFBgND9zQtg7dPYavw82jCkjb7jgU+kVqxzpVVLv7LSAKnj8WM/H0taOPxQv23b1E9CK 8bQUbWwD7XcePKCGeoVcn2MJgWu8zKR72fsk8UsFack62HBP1f8Jxd0efdxh+i7aGYv6 uBWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="NpAcFyZ/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id cb6-20020a056a02070600b005b909afef1fsi10903939pgb.518.2023.11.15.17.29.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 17:29:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="NpAcFyZ/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 814288106835; Wed, 15 Nov 2023 17:29:32 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344331AbjKPB3X (ORCPT + 99 others); Wed, 15 Nov 2023 20:29:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232310AbjKPB3U (ORCPT ); Wed, 15 Nov 2023 20:29:20 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 630A8198 for ; Wed, 15 Nov 2023 17:29:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700098156; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Rr9/qVNLgFGWDGzcAqjV00T9t0NzgxXDD6w387jcEYI=; b=NpAcFyZ/9LB3zx3oT/POa/0V2bySj9fzQ3llny5quZ0hpVWWU8UQvR7KYlxunEAezmlwtO I0S+oxN/XNvDnuzVJo5ZGx7xLRfFsohMFmNM8S1KFlAK2u7FAHL8pSBTv2l901oxbFj1CD B3qNCRouZ7dNzcuTKcW5l9ramCiuagk= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-648-k_u7GC7_NJ-Y33KqFAf5PA-1; Wed, 15 Nov 2023 20:29:15 -0500 X-MC-Unique: k_u7GC7_NJ-Y33KqFAf5PA-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-66d7b75c854so807456d6.1 for ; Wed, 15 Nov 2023 17:29:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700098154; x=1700702954; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Rr9/qVNLgFGWDGzcAqjV00T9t0NzgxXDD6w387jcEYI=; b=BdPGsJeQu0Z0N2pfLtaUMJWeIHJtmzwICZki8zMTcpwuBZoZXBOWCCJkLuMExhbViZ BBN+fUb/AV2MkeUrvwZb1AYh3ur/+JMnevRCKD6E39QiGjX3PLhKKaqfmeKsHKZg2nd7 QwNFJw5lgTLcnsqDMVON9wJnd0Toc6r/4ulN1PkMnuPBKT3YpgVVVZtYychmM8vCxFFL Q0i0u6cKsOT2agxYmbLfQXWIcVLoSZEvQ3sQ0+0cRdDPlsjbAUn2DZUwhTARqmTniLJw ED72deEFFc92CSnKvfCbWWrekosI3d7nyYLh9Q4bHep9XLBh000m3Escdh1d7joeflic YMOw== X-Gm-Message-State: AOJu0YxCiidt9RGVCXI7Oa82aMBQjZsg/EVR0t0E1nsC4w7rQg5gM97k zXZ27y2OQSwMsg3vE8VniVHMMQckjRzhWYuvhlxnGgsxFZS7xhX/DB7kLPOLOfrYc9GRuGuxQpy zWjt6y8dOswCRi2Uy/hMjGsj+cYOcFDr6KJlGSC6eWQfZA0SY/m1zLjNMVtvv8CyWs+IqDSEhZO +qd+sHmg== X-Received: by 2002:ac8:5189:0:b0:421:c275:f917 with SMTP id c9-20020ac85189000000b00421c275f917mr7201803qtn.6.1700098154738; Wed, 15 Nov 2023 17:29:14 -0800 (PST) X-Received: by 2002:ac8:5189:0:b0:421:c275:f917 with SMTP id c9-20020ac85189000000b00421c275f917mr7201781qtn.6.1700098154444; Wed, 15 Nov 2023 17:29:14 -0800 (PST) Received: from x1n.redhat.com (cpe5c7695f3aee0-cm5c7695f3aede.cpe.net.cable.rogers.com. [99.254.144.39]) by smtp.gmail.com with ESMTPSA id c24-20020ac85198000000b0041e383d527esm3922598qtn.66.2023.11.15.17.29.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 17:29:14 -0800 (PST) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Mike Kravetz , "Kirill A . Shutemov" , Lorenzo Stoakes , Axel Rasmussen , Matthew Wilcox , John Hubbard , Mike Rapoport , peterx@redhat.com, Hugh Dickins , David Hildenbrand , Andrea Arcangeli , Rik van Riel , James Houghton , Yang Shi , Jason Gunthorpe , Vlastimil Babka , Andrew Morton Subject: [PATCH RFC 02/12] mm: Provide generic pmd_thp_or_huge() Date: Wed, 15 Nov 2023 20:28:58 -0500 Message-ID: <20231116012908.392077-3-peterx@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231116012908.392077-1-peterx@redhat.com> References: <20231116012908.392077-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 15 Nov 2023 17:29:32 -0800 (PST) ARM defines pmd_thp_or_huge(), detecting either a THP or a huge PMD. It can be a helpful helper if we want to merge more THP and hugetlb code paths. Make it a generic default implementation, only exist when CONFIG_MMU. Arch can overwrite it by defining its own version. For example, ARM's pgtable-2level.h defines it to always return false. Signed-off-by: Peter Xu --- include/linux/pgtable.h | 4 ++++ mm/gup.c | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index af7639c3b0a3..6f2fa1977b8a 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -1355,6 +1355,10 @@ static inline int pmd_write(pmd_t pmd) #endif /* pmd_write */ #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ +#ifndef pmd_thp_or_huge +#define pmd_thp_or_huge(pmd) (pmd_huge(pmd) || pmd_trans_huge(pmd)) +#endif + #ifndef pud_write static inline int pud_write(pud_t pud) { diff --git a/mm/gup.c b/mm/gup.c index 231711efa390..a8b73a8289ad 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -3002,8 +3002,7 @@ static int gup_pmd_range(pud_t *pudp, pud_t pud, unsigned long addr, unsigned lo if (!pmd_present(pmd)) return 0; - if (unlikely(pmd_trans_huge(pmd) || pmd_huge(pmd) || - pmd_devmap(pmd))) { + if (unlikely(pmd_thp_or_huge(pmd) || pmd_devmap(pmd))) { /* See gup_pte_range() */ if (pmd_protnone(pmd)) return 0; -- 2.41.0