From patchwork Fri Nov 25 03:45:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 13055483 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 D4C6BC4167B for ; Fri, 25 Nov 2022 03:45:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C53656B0071; Thu, 24 Nov 2022 22:45:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C03756B0072; Thu, 24 Nov 2022 22:45:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AF28B6B0073; Thu, 24 Nov 2022 22:45:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id A03306B0071 for ; Thu, 24 Nov 2022 22:45:17 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 669BE1C63D9 for ; Fri, 25 Nov 2022 03:45:17 +0000 (UTC) X-FDA: 80170574274.08.CC266A1 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf18.hostedemail.com (Postfix) with ESMTP id 123261C000A for ; Fri, 25 Nov 2022 03:45:15 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8ED0C23A; Thu, 24 Nov 2022 19:45:21 -0800 (PST) Received: from a077893.arm.com (unknown [10.163.44.13]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A131B3F73D; Thu, 24 Nov 2022 19:45:11 -0800 (PST) From: Anshuman Khandual To: linux-mm@kvack.org Cc: Anshuman Khandual , Christian Borntraeger , David Hildenbrand , Heiko Carstens , Andrew Morton , kvm@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] s390/mm: Use pmd_pgtable_page() helper in __gmap_segment_gaddr() Date: Fri, 25 Nov 2022 09:15:02 +0530 Message-Id: <20221125034502.1559986-1-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669347916; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=BnFYGPk8DaCeuznpXsmspX2q6lqMEDJjdBKAQ7NW43Y=; b=qhyBGCt3lEPfxqrVtPOwL/bBBhVFjkNoyLlsokAi3iXDZ0O2RM8MvjNeaqwRDZuz8Ll67V fZj1AG+YKKqtCGjL+Xg0dYrPIDaiDVpQ5JkbiWGpw7g8u1/3at/xqKAdzxo45h/1OLfs/5 v5oQg+fVmxL8qQKUY2A7MfSGITaYD9s= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1669347916; a=rsa-sha256; cv=none; b=PFnrjJkvMVkn0ek3RvOxdE6GnVT7nnBo0ZvxF6OkLQry5ZAIu4wOIL4+Ft3O+V9w8GLVR0 nvjg8sGihaY7f8JR8GPQgX+p896Vw+4SBt7ahY6/hOMupr8In84gf1Aw+OE1U3mJyjzYS9 0AQWmYwuopoqgochxB0tepFbI52ZF/U= X-Rspamd-Queue-Id: 123261C000A Authentication-Results: imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com; dmarc=pass (policy=none) header.from=arm.com X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: pc96uped8b7hz9xr9nwaz9yxrt45s9uu X-HE-Tag: 1669347915-889234 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: In __gmap_segment_gaddr() pmd level page table page is being extracted from the pmd pointer, similar to pmd_pgtable_page() implementation. This reduces some redundancy by directly using pmd_pgtable_page() instead, though first making it available. Cc: Christian Borntraeger Cc: David Hildenbrand Cc: Heiko Carstens Cc: Andrew Morton Cc: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org Signed-off-by: Anshuman Khandual Acked-by: Alexander Gordeev --- This applies on v6.1-rc6 but after the following patch. Build tested for s390 plaform (defconfig). https://lore.kernel.org/all/20221124131641.1523772-1-anshuman.khandual@arm.com/ arch/s390/mm/gmap.c | 5 ++--- include/linux/mm.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c index 02d15c8dc92e..8947451ae021 100644 --- a/arch/s390/mm/gmap.c +++ b/arch/s390/mm/gmap.c @@ -336,12 +336,11 @@ static int gmap_alloc_table(struct gmap *gmap, unsigned long *table, static unsigned long __gmap_segment_gaddr(unsigned long *entry) { struct page *page; - unsigned long offset, mask; + unsigned long offset; offset = (unsigned long) entry / sizeof(unsigned long); offset = (offset & (PTRS_PER_PMD - 1)) * PMD_SIZE; - mask = ~(PTRS_PER_PMD * sizeof(pmd_t) - 1); - page = virt_to_page((void *)((unsigned long) entry & mask)); + page = pmd_pgtable_page((pmd_t *) entry); return page->index + offset; } diff --git a/include/linux/mm.h b/include/linux/mm.h index e9e387caffac..5ead9e997510 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2403,7 +2403,7 @@ static inline void pgtable_pte_page_dtor(struct page *page) #if USE_SPLIT_PMD_PTLOCKS -static struct page *pmd_pgtable_page(pmd_t *pmd) +static inline struct page *pmd_pgtable_page(pmd_t *pmd) { unsigned long mask = ~(PTRS_PER_PMD * sizeof(pmd_t) - 1); return virt_to_page((void *)((unsigned long) pmd & mask));