Received: by 2002:a19:771d:0:0:0:0:0 with SMTP id s29csp1270694lfc; Wed, 1 Jun 2022 13:44:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyN/QfpZ84dB18R7x/4t2w7RRPKBYGoSi6OkA7Y+ged8vQDqCm88Y8CNnS9Ys1vYmpjiUuo X-Received: by 2002:a05:6a00:9a6:b0:518:fb72:5e2e with SMTP id u38-20020a056a0009a600b00518fb725e2emr1397983pfg.55.1654116275957; Wed, 01 Jun 2022 13:44:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654116275; cv=none; d=google.com; s=arc-20160816; b=GjJcjSpRBFULEWMH4+DL225jWoXty1PFvu8WARoAvl1Zh6S4BcLvgBaG+nqdab/MRC SCx+0dVb0thZDsOFJzdFUTPOvTDSwFEqu53Howsi+YtJ1gKNm1CdZzawotgerz+ezDmn uFkvw5Wo7Tcm6SycKlLQuGTmq5vuGsMVnwfA+IvTEW9kSqEm823w9F5LFVpXuWtohEKu laZb0/gMgQgrDag/EkwCXQyIs3q5jz0DWiRJ+DFf15+8ktqW7hpisT52QIulCoIh8OrQ lNLOw+WIGSZJkV1SiRzT05PC0ndY7ue13W34/ceFTow6q5LmYCBsgngPn0qHBNAHwi4y 7uWw== 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=0rUpiaaAumJQHZ2NkgE4OtbYqIKcbspra9WP2rXAErY=; b=t8sjzGJvCXqPMD0b1OlL2nysR3Kqi1O6yJY+jfBtOKD5cx/5AKRdqOfRlWfNOOCXwb Bwo4ULzZPN2A8ScvpUC1C9SbGe2bxHmer2a/mTltfTJFgMRBKes3aP1Sw8SpwHzwEzdm wDaUVzioAqkanZxafYRnoLwPH2db2ypycPPSwZIRpS75kDu50PE8ig90FMyhMuNHLSvm YfIcmx/Y4QpQ3/ZOvpNA9raNpmIbBxfw9ZoBMJnDjs/LSsBewpQRVeQ9J2cjNtR8RSNk Wl9pg4vCwnK7M+xXySy9bTIhl6tKXMYzWD1YiYHGbttCwgPaSK57Sla3/wSTNmpomMzy T0bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=Dqx2RXLR; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 145-20020a630597000000b003f5f0a397e6si3521873pgf.814.2022.06.01.13.44.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 13:44:35 -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=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=Dqx2RXLR; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8FF3529F597; Wed, 1 Jun 2022 12:52:30 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243473AbiEaCEm (ORCPT + 99 others); Mon, 30 May 2022 22:04:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235432AbiEaCEf (ORCPT ); Mon, 30 May 2022 22:04:35 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2B957A813 for ; Mon, 30 May 2022 19:04:33 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id l7-20020a17090aaa8700b001dd1a5b9965so851745pjq.2 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=iu7Ro7/U3KAZsrdKRiaEY5aZRKDKksmDrWtTpFTIZQkUoXu/jOPpVoJoF+72AkV7Ta x6m3lAdZib+i50e1BgmZNP7/xWQ63xhmWghUuKmhYU4clzxLTRgA4k6IatgGokllIZzm pLON9+rYYkxDV5MM005Jf/8A5MlSuH/9oJyWm0WjL5YpYwUqyx5xeQrZ45ibU73/Ber0 fLn1N/cJzJKhgZis/WzviihmFEPhk+sXp8dqFW2Msw1JuRcILwUp0ZTLiJKSP1gqureF V2rR/JFMDq3s/Ctvfj2ODfFTvIvYH4N4NsHp4ZG6NLkHQXu9FLXmOA2KrEx6p/5yAX/G G4Ug== X-Gm-Message-State: AOAM531jfai2qbdp0vw0Kx2DhFM39Ninp42AP++veDt/rsxCgXohEBMM FnyuaxpY0KebMnbSzM9mc7r1ng== 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 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 > >