Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp628349ybz; Wed, 29 Apr 2020 06:39:16 -0700 (PDT) X-Google-Smtp-Source: APiQypKcbzi1510NtbiXjTfkadWLnnHxGptc5UhuRH9gf/zFeaVZzdfrvdThLUNTW+WMBXAqS1XL X-Received: by 2002:a17:906:f295:: with SMTP id gu21mr2688335ejb.83.1588167556746; Wed, 29 Apr 2020 06:39:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588167556; cv=none; d=google.com; s=arc-20160816; b=Q9kzK/ENY6RmIDOIdrxw2wznedBa/0BS69/S5G8TYuoE9Mf27bJ1juHzl7c6LYg3pL QHrARPEOoV82CNjOwV55hG9uNXA/Kj2zNMVlEXEz+zDULvc3nGDBgzNervOlKyqiXLx5 G12M6vbqNGr6EhbIyM02Pfpilf84cooOlXs2orE2Ub1TX+pPEbVdnL52kLkbEUqNxluF NCFUXXBq69xbWibeAj5qXe1nn0t12qSBXgwQi7pzJkbL+noaS83Z5nOR15bUiwMTw/JT 6rMWDj2Bo3iries6WDYUbeWtW8UUH28TJ4xoxSXzlyaZWoZupPKprC1QpHpfPK/9HdNO pcqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Yi1wYt4iXlkSO38vWez4amiBBSDF7tSr77p/65sccCE=; b=JIcy4CS1/8n80EAwwtYbazK1ZM4Iqk4l7rntvStf8EVEH+ZlB//mb/+IYV1oGg8mOx fw2UnDRVgIudXNUqW3kB+GgvDw4qKohKHg7WRlcpNgbZX4x6yx1bVnlRNZxZZUC4lRON kpKxrPQXTKiBjNC5YLymqFMp6xCLN6YHdzNJpE8mTROicBirSy1WSg5PDDT1hRIMGPGW EsmaxnwmtDmg7z0sCxUft4lJZX0twv/54Xu2C6S74AnAJi6xQpVTw+L9yHS01zF7iHuF lk3IoZnyzRJXh2LPTWljNn/TG5gpV+p1ISW71V67j+ZCjmKxy7fwKj++zEQNv1tfZ0KE QKOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=SZc9+QON; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z5si2534782edj.29.2020.04.29.06.38.52; Wed, 29 Apr 2020 06:39:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=SZc9+QON; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727786AbgD2NhG (ORCPT + 99 others); Wed, 29 Apr 2020 09:37:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726835AbgD2Ng7 (ORCPT ); Wed, 29 Apr 2020 09:36:59 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61896C035495; Wed, 29 Apr 2020 06:36:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=Yi1wYt4iXlkSO38vWez4amiBBSDF7tSr77p/65sccCE=; b=SZc9+QONeaWnQfhpZwMykTT0We gzaZj2YKRGIYSlnXGd+e23wDBmGYEAYxqpT78aApEI3LyzjZ84XCMRxSv9kuXJJw+vQXa7SoYppXd pVyDoz+hUZSCDSnLqRfwfXp50wQbt/rptwJ2sPcX/LfDx7V7W8KzK8U6+cWmhf88XkQ4Cb0V8qFU6 Z73OXdNi4/Nq/EEbjbN32WJoLPWDdEMSuOPVUTWcvzAwAyPmIhGWlLo4DxqS51pfJGDFbfTACszb5 V9G87+OG9myxtn+UxccqD7HPrVKC3R9d8M05VwVZp2OAAgtNI2r1AfBV8ALYFkfrCvS52L8ZY7eoN aJw7KWvg==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jTmtX-0005uZ-75; Wed, 29 Apr 2020 13:36:59 +0000 From: Matthew Wilcox To: linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 04/25] mm: Introduce offset_in_thp Date: Wed, 29 Apr 2020 06:36:36 -0700 Message-Id: <20200429133657.22632-5-willy@infradead.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200429133657.22632-1-willy@infradead.org> References: <20200429133657.22632-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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)) /* * Flags passed to show_mem() and show_free_areas() to suppress output in -- 2.26.2