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 06B73C433F5 for ; Mon, 30 May 2022 19:56:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3F7796B0071; Mon, 30 May 2022 15:56:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 37C206B0072; Mon, 30 May 2022 15:56:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1F3296B0073; Mon, 30 May 2022 15:56:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 0BE766B0071 for ; Mon, 30 May 2022 15:56:50 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id C72CA35486 for ; Mon, 30 May 2022 19:56:49 +0000 (UTC) X-FDA: 79523467338.02.0F7CAD2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf21.hostedemail.com (Postfix) with ESMTP id 35A931C004C for ; Mon, 30 May 2022 19:56:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653940608; 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=SrQHuKkuR8CrrdLyf+7/DQkTTkrKszGSGsUUA8WbICA=; b=ENhqMlIQCB8VmpWLc5cr+gknYoM7DjX6fLEfmaIAOejNn+69HrSIAJFahIHdKjCpnSsuwS i/TUwaAiiRp9/cS71k3khs60KWnRMSYfna4cIVSGe4wLlJBDZF88rlAxOCqzSVs0f2bycV /PofzANUgqzGn84h59sQSzczkPyw8ag= Received: from mail-io1-f72.google.com (mail-io1-f72.google.com [209.85.166.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-294-VdnEZdcVNcymzroQctnFfg-1; Mon, 30 May 2022 15:56:47 -0400 X-MC-Unique: VdnEZdcVNcymzroQctnFfg-1 Received: by mail-io1-f72.google.com with SMTP id ay41-20020a5d9da9000000b006685ce50214so3369706iob.22 for ; Mon, 30 May 2022 12:56:47 -0700 (PDT) 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:message-id:references :mime-version:content-disposition:in-reply-to; bh=SrQHuKkuR8CrrdLyf+7/DQkTTkrKszGSGsUUA8WbICA=; b=KCK1qwoO+/UB8VazikYfpd2/+TX/mxy2ylMwXoLOsH765ovfkEo9lvxDo3mr51REZE SxTQ2Twd6HM7lMkLnSBXRse/GPOWHnHLffyq/xNOIXWQBCnpwaLrzU37FV9UHfAjlARn HqGBTy/QTR97GoRfk2rMh4tWWGQAqyVEGCJuRbYkTEShPlzRR6c/G4/bdKTL83mrpxj9 trV8l7xmTX5MshUbAbGG3VPYf3YQSuz1j9bH7XfZ27wdsYSVsp6dbltlBWsSWmXX768I q7auwijO7yb3P/v+tUt/kxB1TVralldIa+Pl3C22LLpQ1n3DrjbZAf0o07s5kMew7Kcv ocKQ== X-Gm-Message-State: AOAM532WFRbH+tCZnFJC0Mdin2kMa4RidAgJpW8ONafndo0kU7jsRlOl FI/0ksIg2mzyI8IXLWSfUVqYEWgzcmP2ZZlfZafpmCYvdqDgN83nn9hXHsTaqBzw3NtboD824Fn 0dVL7jdMjwBc= X-Received: by 2002:a05:6638:25d3:b0:32e:e5ee:496c with SMTP id u19-20020a05663825d300b0032ee5ee496cmr16603123jat.52.1653940606496; Mon, 30 May 2022 12:56:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwx3+eDeVC1tEGsUjSxkWbRjFFdRh89vPjGO12nGBme87S4wjpsuBO4lyT0OcGY9695AehSpg== X-Received: by 2002:a05:6638:25d3:b0:32e:e5ee:496c with SMTP id u19-20020a05663825d300b0032ee5ee496cmr16603114jat.52.1653940606320; Mon, 30 May 2022 12:56:46 -0700 (PDT) Received: from xz-m1.local (cpec09435e3e0ee-cmc09435e3e0ec.cpe.net.cable.rogers.com. [99.241.198.116]) by smtp.gmail.com with ESMTPSA id b16-20020a6be710000000b00665f77d74d6sm3364787ioh.51.2022.05.30.12.56.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 May 2022 12:56:45 -0700 (PDT) Date: Mon, 30 May 2022 15:56:43 -0400 From: Peter Xu To: Mike Kravetz Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Muchun Song , Michal Hocko , Naoya Horiguchi , James Houghton , Mina Almasry , "Aneesh Kumar K . V" , Anshuman Khandual , Paul Walmsley , Christian Borntraeger , Andrew Morton Subject: Re: [RFC PATCH 1/3] hugetlb: skip to end of PT page mapping when pte not present Message-ID: References: <20220527225849.284839-1-mike.kravetz@oracle.com> <20220527225849.284839-2-mike.kravetz@oracle.com> MIME-Version: 1.0 In-Reply-To: <20220527225849.284839-2-mike.kravetz@oracle.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ENhqMlIQ; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf21.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=peterx@redhat.com X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 35A931C004C X-Stat-Signature: 4fd6o1cjp5rnh6pacquc35kji7c1p8wj X-HE-Tag: 1653940595-630553 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: Hi, Mike, On Fri, May 27, 2022 at 03:58:47PM -0700, Mike Kravetz wrote: > +unsigned long hugetlb_mask_last_hp(struct hstate *h) > +{ > + unsigned long hp_size = huge_page_size(h); > + > + if (hp_size == P4D_SIZE) > + return PGDIR_SIZE - P4D_SIZE; > + else if (hp_size == PUD_SIZE) > + return P4D_SIZE - PUD_SIZE; > + else if (hp_size == PMD_SIZE) > + return PUD_SIZE - PMD_SIZE; > + > + return ~(0); > +} How about: unsigned long hugetlb_mask_last_hp(struct hstate *h) { unsigned long hp_size = huge_page_size(h); return hp_size * (PTRS_PER_PTE - 1); } ? This is definitely a good idea, though I'm wondering the possibility to go one step further to make hugetlb pgtable walk just like the normal pages. Say, would it be non-trivial to bring some of huge_pte_offset() into the walker functions, so that we can jump over even larger than PTRS_PER_PTE entries (e.g. when p4d==NULL for 2m huge pages)? It's very possible I overlooked something, though. Thanks, -- Peter Xu