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 DE36CC433F5 for ; Tue, 31 May 2022 02:04:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4929A6B0073; Mon, 30 May 2022 22:04:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 440E76B0078; Mon, 30 May 2022 22:04:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2692C6B0074; Mon, 30 May 2022 22:04:36 -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 0E7A76B0072 for ; Mon, 30 May 2022 22:04:36 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id CB72A20399 for ; Tue, 31 May 2022 02:04:35 +0000 (UTC) X-FDA: 79524394110.20.DE5E823 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by imf04.hostedemail.com (Postfix) with ESMTP id 4168140035 for ; Tue, 31 May 2022 02:04:15 +0000 (UTC) Received: by mail-pj1-f44.google.com with SMTP id w2-20020a17090ac98200b001e0519fe5a8so847176pjt.4 for ; Mon, 30 May 2022 19:04:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=0rUpiaaAumJQHZ2NkgE4OtbYqIKcbspra9WP2rXAErY=; b=Dqx2RXLRsbRyQCJvVUvEIK951cc8Lk5L8nZraZQKbjv9j30rL44DZLtO0F6LcWeUIi VzbfUgYYjRZ5giAK9UN2+MUputllcs/bf27mS3Y/JVTAA1DDUeSDmTf5V2QQXhWQHfUR SW7xB6AetVIDOK+kpvzCaj3UIT6XnnRof3HvX7bO9c+2KcYh/xJxOaGvDo+LQMBMIEPQ bOJoRkRooVNe1cRQkQ4ULn1k8PCT1KK5hMGd0YkX+MRE+zqDkC5mqAfmAfyWb4IugxWo SkFCREfMVTSarMgbJwuGgPVnsvMnkvLWB5qX70MaUy//KEtg3tKj6IF+vggZ/OqIY6V2 hJaw== 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=0rUpiaaAumJQHZ2NkgE4OtbYqIKcbspra9WP2rXAErY=; b=BSso35xIHL9c8qy1zkzBvzMZrs/NmaVgBlJyat8Yv9A8g+2iIS6AK9MAapWdhQ7GSl BtTTKrlc/wWMHll4opcoXQgAIRNMsDLMDqyMe8aFYpPbG3j1x4gh2zgH4KL8tFYKyCL3 LolGsWNE3fmEyjRJNxYWdtWGk9IBOeHNjjIOi5ZePMlAgr+p9aBn+wWlZdgWhTd7f+UN Cnd2tT/h5sIgW0ZZyo+/HzzMu6TVi7qZydLtzK7R+8rrKJoZB4FETyRjqz7/p/5f1SV3 yES73YELpF1Hch4+KV/z7qQvE0SShoX6be53vn2pZ/eXNf6F/zCMK85C27iaf4OZ+0z+ 0Elw== X-Gm-Message-State: AOAM530IgzGX9kAmUvbY3sDggZXtDSwn8FkWM/rzCns7FKUgwSVf4Xm+ Eh36EQ0CDnyl7k9zEgm+fUzlkA== X-Google-Smtp-Source: ABdhPJzjdEbJLrtya8nVyD+MufcjXBFv8zXPpvNY45MyBTk8VcnJdbGnpc5+wN1L71F2EgRHB7UTEA== X-Received: by 2002:a17:90a:5291:b0:1e0:cf4a:b6fa with SMTP id w17-20020a17090a529100b001e0cf4ab6famr26405737pjh.197.1653962672802; Mon, 30 May 2022 19:04:32 -0700 (PDT) Received: from localhost ([2408:8207:18da:2310:7163:3a36:783f:6d4a]) by smtp.gmail.com with ESMTPSA id p3-20020a170903248300b00161955fe0d5sm2486044plw.274.2022.05.30.19.04.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 May 2022 19:04:32 -0700 (PDT) Date: Tue, 31 May 2022 10:04:26 +0800 From: Muchun Song To: Peter Xu Cc: Mike Kravetz , linux-kernel@vger.kernel.org, linux-mm@kvack.org, 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=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 4168140035 X-Stat-Signature: musjpjjtkqqbzkr5djr9sippa4dnxhza Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=Dqx2RXLR; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf04.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.216.44 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com X-Rspam-User: X-HE-Tag: 1653962655-9081 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: On Mon, May 30, 2022 at 03:56:43PM -0400, Peter Xu wrote: > 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); > } > +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 > >