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 34682C433EF for ; Tue, 28 Jun 2022 17:08:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BF24F8E0003; Tue, 28 Jun 2022 13:08:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BA2D18E0001; Tue, 28 Jun 2022 13:08:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A90C78E0003; Tue, 28 Jun 2022 13:08:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 9BE978E0001 for ; Tue, 28 Jun 2022 13:08:30 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 615A4814CB for ; Tue, 28 Jun 2022 17:08:30 +0000 (UTC) X-FDA: 79628278380.02.979D632 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by imf28.hostedemail.com (Postfix) with ESMTP id D2EF7C001A for ; Tue, 28 Jun 2022 17:08:29 +0000 (UTC) Received: by mail-pl1-f176.google.com with SMTP id k14so11647753plh.4 for ; Tue, 28 Jun 2022 10:08:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=QFV2WnYNeaDY0J8D3DnyqJ0OcOi782Ccy54kvG1tyHE=; b=oAkICj/+ZyN8qPXqe9kShQ/snbNFhTGd0rgmxxy+FfN4hkyVSdT9dDhDNH9UVT4j3D 5iFALxNdYoSZDDHeBa8bqZT8C9M4XwsAJt6BZENTwjXNOCvHd8haaIz9BkJJoJGU6hXi BZvPt1pljnePXzfcZbYlzgY+EHBirVKdIN3QFttXSlG/Ehpyr/W5mpl/awZHsFSVOUTK l/Iv9cOFV/CyemWDI/b7uS1aaeF/CD6CM8Il/8q6G/1qP/NXEs6Iu8WplAcvz0Rz6yje 55XuzdphDAee7nJxtXHok/9X+Pg20/fIztvFbhYUVJp1ngKqbX1ZMTeiN80ssGVhHAna Uc3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=QFV2WnYNeaDY0J8D3DnyqJ0OcOi782Ccy54kvG1tyHE=; b=mgyluMql8Jeb3EiGQlLAYQueiHDtpOuoy/kTJIPUpyQOmGFc+ASGW7JFlhEaauwC0N KzdEtW4RAvt6ly1OALEDtkLt5Paag6WIsDe7PXJVZ+TPBDv7Q5uo6JrEZcrDWk8jP51F 0M5dAwYGlyJQLtgEMM2mvLv449jDr8HQXDx9/Jg98JkgXCqPHUlTRRiTuBt345n7s9S2 c0tAfkuC0/ZadqXjB8ENR9QWOEgQKKeQ555rfnmOi5JNs4gK27KxJLM1Pp9pFiutujXp kssjSwLLozdD4fSa34C6y5oLekgzVj3Y1kQNgYYGoROEMdnLEQGS8K+XbXs0Tya2Pn2f 8yrA== X-Gm-Message-State: AJIora+YTnb5pNSwhX12cuaRKzOBmX9JZbI2llpg1DkZN+xKvMFZlsle w3QwFFiqA1NasyFfEdL444Lm7765RAjN5L9znrztsw== X-Google-Smtp-Source: AGRyM1tH5SSZQk6DAH0mC95qYZ5+THIX8CIOWKNGgx4CLL16zjo5paPViUVRD51b3QHtWGTwT+/Get8p3c2v7m7Dnt8= X-Received: by 2002:a17:90b:4f45:b0:1ed:3fe:e54 with SMTP id pj5-20020a17090b4f4500b001ed03fe0e54mr732682pjb.32.1656436108709; Tue, 28 Jun 2022 10:08:28 -0700 (PDT) MIME-Version: 1.0 References: <20220624173656.2033256-1-jthoughton@google.com> <20220624173656.2033256-2-jthoughton@google.com> In-Reply-To: From: James Houghton Date: Tue, 28 Jun 2022 10:08:18 -0700 Message-ID: Subject: Re: [RFC PATCH 01/26] hugetlb: make hstate accessor functions const To: "manish.mishra" Cc: Mike Kravetz , Muchun Song , Peter Xu , David Hildenbrand , David Rientjes , Axel Rasmussen , Mina Almasry , Jue Wang , "Dr . David Alan Gilbert" , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="oAkICj/+"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf28.hostedemail.com: domain of jthoughton@google.com designates 209.85.214.176 as permitted sender) smtp.mailfrom=jthoughton@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656436109; a=rsa-sha256; cv=none; b=7X69ApngzjGrsv8IMkZlvLzAnJvWKJvVblQAWBouqrt38iPXEq2eehQbit+o+ik0WUfukw wpPEJeKrcnJE30RlNSB3vLHEK2DnZx8ejrwogpKAyUHsXaGuHacUyJBauR2BOo91BZH4+C TcKes15eXRQLgWJmS2BLYfMm5oJlFX4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656436109; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=QFV2WnYNeaDY0J8D3DnyqJ0OcOi782Ccy54kvG1tyHE=; b=GL6FAlWEOn1GLnTWU1eIEfBLprXaqGCt3yd5QgukTy8AwQ6Rkn9fjmblU/e4o+UyebE6x1 YrABAot1c4JSuFExhRe4yf61rTy+Pe6zPF4C8tJJgPTbaSIt2MiFk5QXl0XFVV82Grtkuq 7fB6AznrQ7viqfTyLEaHCyyyd+2cPgE= X-Stat-Signature: 7zquwmjewrewwfbiu3sqipxn1p3kqgpy X-Rspamd-Server: rspam08 X-Rspam-User: X-Rspamd-Queue-Id: D2EF7C001A Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="oAkICj/+"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf28.hostedemail.com: domain of jthoughton@google.com designates 209.85.214.176 as permitted sender) smtp.mailfrom=jthoughton@google.com X-HE-Tag: 1656436109-274190 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, Jun 27, 2022 at 5:09 AM manish.mishra wrote: > > > On 27/06/22 5:06 pm, manish.mishra wrote: > > > On 24/06/22 11:06 pm, James Houghton wrote: > > This is just a const-correctness change so that the new hugetlb_pte > changes can be const-correct too. > > Acked-by: David Rientjes > > Signed-off-by: James Houghton > --- > include/linux/hugetlb.h | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h > index e4cff27d1198..498a4ae3d462 100644 > --- a/include/linux/hugetlb.h > +++ b/include/linux/hugetlb.h > @@ -715,7 +715,7 @@ static inline struct hstate *hstate_vma(struct vm_area_struct *vma) > return hstate_file(vma->vm_file); > } > > -static inline unsigned long huge_page_size(struct hstate *h) > +static inline unsigned long huge_page_size(const struct hstate *h) > { > return (unsigned long)PAGE_SIZE << h->order; > } > @@ -729,27 +729,27 @@ static inline unsigned long huge_page_mask(struct hstate *h) > return h->mask; > } > > -static inline unsigned int huge_page_order(struct hstate *h) > +static inline unsigned int huge_page_order(const struct hstate *h) > { > return h->order; > } > > -static inline unsigned huge_page_shift(struct hstate *h) > +static inline unsigned huge_page_shift(const struct hstate *h) > { > return h->order + PAGE_SHIFT; > } > > -static inline bool hstate_is_gigantic(struct hstate *h) > +static inline bool hstate_is_gigantic(const struct hstate *h) > { > return huge_page_order(h) >= MAX_ORDER; > } > > -static inline unsigned int pages_per_huge_page(struct hstate *h) > +static inline unsigned int pages_per_huge_page(const struct hstate *h) > { > return 1 << h->order; > } > > -static inline unsigned int blocks_per_huge_page(struct hstate *h) > +static inline unsigned int blocks_per_huge_page(const struct hstate *h) > { > return huge_page_size(h) / 512; > } > > James, Just wanted to check why you did it selectively only for these functions > > why not for something like hstate_index which too i see used in your code. I'll look into which other functions can be made const. We need huge_page_shift() to take `const struct hstate *h` so that the hstates can be sorted, and it then followed to make the surrounding, related functions const as well. I could also just leave it at huge_page_shift(). The commit message here is wrong -- the hugetlb_pte const-correctness is a separate issue that doesn't depend the constness of hstates. I'll fix that -- sorry about that.