Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp5765648ioo; Wed, 1 Jun 2022 12:06:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYxUiFYMPzSldyfuBMhecZweOHY6ebnxj4+fzCjZwTSG+/ly1bjDMBhD845bKpIDf8UUMe X-Received: by 2002:a62:d145:0:b0:51b:4376:e761 with SMTP id t5-20020a62d145000000b0051b4376e761mr1015960pfl.11.1654110385271; Wed, 01 Jun 2022 12:06:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654110385; cv=none; d=google.com; s=arc-20160816; b=K0xVZknLJ5ch6bqKIn7EXNKEqIofIUu5ZBHde3xrn4szH50ggs53Q9LFH2r1QdRhqh i1h6NZ3HLh7yjt88b0eCAJlYJIKkXWYwhiSZVz8GFNrI0VnD0K367qCfE8Gl99vpu9+s WbrovsEyD1wXhclxgp+ruA4Jm3YqRmTSixfH+E/xBFnd6lc7hSxUj5dWENvHYW2J8ooH 8BZnD5cjD4mG3zlUb0AYNaYpc7pxY8jRTOb3Hjjyal/B7kf++72Cr1w2An+j9SwANbGo I/sKkDs+OHFS2savKnbT/4EhdavDyskX081WiF/LV32M6XP0wK+elItP7gc3W4KAIXfm 1kpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=SrQHuKkuR8CrrdLyf+7/DQkTTkrKszGSGsUUA8WbICA=; b=kgJ+QJ1OUj88H3cEJj5HkbhHEEA+V0gI0yHRI/vFdjtYe8bYfgqeRRGrDOnVgxVE7F 3YBKB9tkSPlTMyrbfzQ7ZDPHqAvyH570TTK1L5Poh+QLyI0Gnwfk0RWH3GMPCU+XCRPl NlaFJ4TRfvfDiLIhOukf3cmMlQpBwd1tkHPkas/QGJ97HV86ulzMQ3Yoz3TtfFXC3V/3 UTntHzoZnDuoehoqDDUTPgz+uMV27UCbZTPpzPP6/8YswwesDDzqzxcmI4DkEpgLz06S lN5Dhs23d3pxjFFCFoyGQkkcXsYMJjWnlPLmfwcT8S76rP/sR1vN//7bWXNxgNDYlIMi fBwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ENhqMlIQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id p14-20020a170902e74e00b00162ba3ef425si3753847plf.439.2022.06.01.12.06.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 12:06:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ENhqMlIQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 68BF01078A3; Wed, 1 Jun 2022 11:47:47 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243090AbiE3T5A (ORCPT + 99 others); Mon, 30 May 2022 15:57:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232698AbiE3T4z (ORCPT ); Mon, 30 May 2022 15:56:55 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7EA999FEC for ; Mon, 30 May 2022 12:56:49 -0700 (PDT) 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-f69.google.com (mail-io1-f69.google.com [209.85.166.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-398-WA6lToafNQ-UsDriutUGUQ-1; Mon, 30 May 2022 15:56:47 -0400 X-MC-Unique: WA6lToafNQ-UsDriutUGUQ-1 Received: by mail-io1-f69.google.com with SMTP id y12-20020a5e920c000000b006657a63c653so5893386iop.11 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=Q+34h/4UJkY5nBrp/8vUEBlkULleHAkJ/18OLoBI6hpHmwwRDsOdBdmuyYQyG9ciDt tdXg3ouHpPhNkpgV0Wb5CtAcyi/DDJI9KVT/ukj+QT6GzaLzH1jhSKOJTFgD7/5XdVAn 1hxkyFtoEaV2//xZ9LCBqU1+LAHHREjyGtdKjfliQTArMSwbbn6bdoLAcO5+EmMJKr9Y EhfQeNaELM12d2g4QbXnnEaIr4KOozTDL0YZCzpgiHnRtczaW5cXbrK58uf819pRu7oJ sxMjuoZzkC5nNCVRc13Q9MVriF2xWwQ6yAtkYMDan9nMdGUAaedixumtorXWgz/J3uok Iu2w== X-Gm-Message-State: AOAM533RgXlSEhlDu09fKzODc+jMlKIv+6lL6hPFjQ2wTyRBL98Px6d4 hiOG8CvF9RQKabwYdYHEJ+ARX0PvDPeJ+NXJnX6H16irsq51XlDtv6uLmSC88DD3UX+TDzXDsJi f7ifei15FM3FNP/vCzNa6i9in X-Received: by 2002:a05:6638:25d3:b0:32e:e5ee:496c with SMTP id u19-20020a05663825d300b0032ee5ee496cmr16603121jat.52.1653940606493; Mon, 30 May 2022 12:56:46 -0700 (PDT) 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 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220527225849.284839-2-mike.kravetz@oracle.com> X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 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