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 X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D44B7C433DF for ; Fri, 22 May 2020 17:15:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7D2112068D for ; Fri, 22 May 2020 17:15:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=shutemov-name.20150623.gappssmtp.com header.i=@shutemov-name.20150623.gappssmtp.com header.b="mzImS0TX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7D2112068D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 22A0680008; Fri, 22 May 2020 13:15:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1B35180007; Fri, 22 May 2020 13:15:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 07ADF80008; Fri, 22 May 2020 13:15:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0160.hostedemail.com [216.40.44.160]) by kanga.kvack.org (Postfix) with ESMTP id DF7FF80007 for ; Fri, 22 May 2020 13:15:18 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 975E76118 for ; Fri, 22 May 2020 17:15:18 +0000 (UTC) X-FDA: 76845005916.04.home64_687e5c20b1b03 X-HE-Tag: home64_687e5c20b1b03 X-Filterd-Recvd-Size: 4052 Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) by imf46.hostedemail.com (Postfix) with ESMTP for ; Fri, 22 May 2020 17:15:17 +0000 (UTC) Received: by mail-lj1-f194.google.com with SMTP id o14so13592384ljp.4 for ; Fri, 22 May 2020 10:15:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=LeM7Gq/64MBHuEtg64n+BDtuTe/p5r/j1B2qVESr88E=; b=mzImS0TXTReSbMWpKcN1vkGpQ8SxUQVlDXsSh5HVc1hcwKMdu0GyRSaaa1fjOZZg5w TYmnJWbzYA+tDj+BcEsstIh66E6fqB5G5HryQJ6z7d59+nQB0xJzryWAH6LOaYNns8PO apeKxryZKUtVIEan1sWKPlWKzpGsi2AUtgEog6KIyVcKIbaWzM5sPuRtlxSHRpNtX+Na yLLkSuXv2v+pjLciZ5I5sWVkK9soA7BPwe1PhsmkeVxUIki42sCR6lb/hFeSSv+90ADg rA6cSV/csy7SBjFRwRHZ0OhpPNoFjWgUxDASmpLSFSiXtbxfQcPp7ghcLQIU8tzKWtW3 OlrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=LeM7Gq/64MBHuEtg64n+BDtuTe/p5r/j1B2qVESr88E=; b=axdlaBM15uDsffem3T/ti7VOC+YtY8W/szXGf5KzChK835RNO9X1fZdeVFXXzxhJ0q uwh9XHg57zrvPdx9zFN5kBwXCYmfxSKfTBWl+De6WPLNhyOL8aIeEJpTOgxFLIpQLL8d fmV8OJfD90D/YkJTPyeatrGISDcJitf4+ddCr+QZPbhS8PbVsGTmS7YYJMpWoqI5IIrO AD2aYZ4r7GAqkwyTaw886zZgJ5Tp5bO3o2qOjT+pYIJHsM3ccScp7Zqssl8l8HX59m98 eSl5euWGvtL+gCSQqK2LR9T/E1TJB5PPrWpW760Au9Woo5GP2gx3HMajtzsEDzc7rn6t 6tEg== X-Gm-Message-State: AOAM533xkkuU1540N6/f/WfK304EJrvC94q7J8TgiF+2IGL9ZobPZTbM Pwe2uATOu+UBSBAnzGjqQXSQ+A== X-Google-Smtp-Source: ABdhPJxXaqF0fu43lDvtFcjLrw4+SKMwMnQWIDz3RTTU/jBzSj7pSYbO0YuYEhqLNbO542TDkT2n6w== X-Received: by 2002:a2e:a58a:: with SMTP id m10mr6187412ljp.347.1590167716344; Fri, 22 May 2020 10:15:16 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id z13sm2539557lfd.7.2020.05.22.10.15.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 10:15:15 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id DA192102046; Fri, 22 May 2020 20:15:17 +0300 (+03) Date: Fri, 22 May 2020 20:15:17 +0300 From: "Kirill A. Shutemov" To: Matthew Wilcox Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 06/36] mm: Introduce offset_in_thp Message-ID: <20200522171517.dltsre7vfdvcrd2m@box> References: <20200515131656.12890-1-willy@infradead.org> <20200515131656.12890-7-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200515131656.12890-7-willy@infradead.org> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000262, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, May 15, 2020 at 06:16:26AM -0700, Matthew Wilcox wrote: > From: "Matthew Wilcox (Oracle)" > > Mirroring offset_in_page(), this gives you the offset within this > particular page, no matter what size page it is. It optimises down > to offset_in_page() if CONFIG_TRANSPARENT_HUGEPAGE is not set. > > Signed-off-by: Matthew Wilcox (Oracle) > --- > include/linux/mm.h | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index 088acbda722d..9a55dce6a535 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -1577,6 +1577,7 @@ static inline void clear_page_pfmemalloc(struct page *page) > extern void pagefault_out_of_memory(void); > > #define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK) > +#define offset_in_thp(page, p) ((unsigned long)(p) & (thp_size(page) - 1)) Looks like thp_mask() would be handy here. -- Kirill A. Shutemov