Message ID | 20221125034502.1559986-1-anshuman.khandual@arm.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3750640wrr; Thu, 24 Nov 2022 19:49:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf5j2ILult/zAol6GFddY/jUq0T9J62YmF4DJUM6qKnqzreiWL4q5HtjbszHbLX+dYWuhKQE X-Received: by 2002:a17:903:3311:b0:188:5242:3b00 with SMTP id jk17-20020a170903331100b0018852423b00mr17126742plb.68.1669348169212; Thu, 24 Nov 2022 19:49:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669348169; cv=none; d=google.com; s=arc-20160816; b=hEH5ZdRYg6+9GUu8rlSjTgxdVXqt9IVahofmqw0+ZWF7EK6l49k/5gdcYM6nU2/Qv+ yJnFItQrmc1s2npKghZhoUrlD0JKgeCl8HPtQmZOzBWcQY1x5yGfuUgcf0XxfN6YhQm0 XmQjDrTf6jo4S/QtPb6t2LTBM6G8/JykQZM2oxpIIfaowddzjOjukXSHvomPjx2NGPm6 rxHsfZjGoAU6/pA5UBwqxRPki6PvEAFEpCOyWl3p062SHHOApc0C0pmiH/J5CLqkMsaW ABTLNxlft5nSFkObcC4m8cHfy1vIDdCazE5IAqTM+cq8NmOoYT9hQse/m+zD+mu4l/qB j05w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=BnFYGPk8DaCeuznpXsmspX2q6lqMEDJjdBKAQ7NW43Y=; b=lGdC3k/P8SpsNL93kI+mcahVMx/Otu3fL4H+7h7O+Ce/KaMN1ubQFhgiHngW9xPF9c hGJRao1FcP7O4mbxsF4+Tn7LRqv1zTt8QwKgjNQMhDOND8qvSrjVDMFewM/oZS5sSZtz LrjWPuPdaN0HpToE+7jap/iDuA5nrZX0XydVF60/6SGSzrT7uvqJ24pCZdMwvP8XaR4o GNvOzsGPVkeu63+ul9gyEz16HAxjKMTFxMvwr9bQECFNcZhI05Vlxq1awERzmLYI0WNC L000CFuihQd70R3VxqzefPaywxWsC605rQvVmw/U6uma56/QeIGo3enBuWBp8mOScHXt 3tSA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k5-20020a170902c40500b00187075ae5f6si3099453plk.461.2022.11.24.19.49.16; Thu, 24 Nov 2022 19:49:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229599AbiKYDpR (ORCPT <rfc822;zxc52fgh@gmail.com> + 99 others); Thu, 24 Nov 2022 22:45:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbiKYDpQ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 24 Nov 2022 22:45:16 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 98C471F628; Thu, 24 Nov 2022 19:45:15 -0800 (PST) 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 <anshuman.khandual@arm.com> To: linux-mm@kvack.org Cc: Anshuman Khandual <anshuman.khandual@arm.com>, Christian Borntraeger <borntraeger@linux.ibm.com>, David Hildenbrand <david@redhat.com>, Heiko Carstens <hca@linux.ibm.com>, Andrew Morton <akpm@linux-foundation.org>, 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750438425728681395?= X-GMAIL-MSGID: =?utf-8?q?1750438425728681395?= |
Series |
s390/mm: Use pmd_pgtable_page() helper in __gmap_segment_gaddr()
|
|
Commit Message
Anshuman Khandual
Nov. 25, 2022, 3:45 a.m. UTC
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 <borntraeger@linux.ibm.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
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 <anshuman.khandual@arm.com>
---
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(-)
Comments
On Fri, Nov 25, 2022 at 09:15:02AM +0530, Anshuman Khandual wrote: Hi Anshuman, > 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. [...] > 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; > } Looks okay to me. > 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)); This chunk does not appear to belong to this patch. Thanks!
On 11/28/22 11:37, Alexander Gordeev wrote: > On Fri, Nov 25, 2022 at 09:15:02AM +0530, Anshuman Khandual wrote: > > Hi Anshuman, > >> 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. > > [...] > >> 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; >> } > > Looks okay to me. > >> 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)); > > This chunk does not appear to belong to this patch. Should not this helper be made a 'static inline' before using it else where ?
On Mon, Nov 28, 2022 at 12:01:06PM +0530, Anshuman Khandual wrote: > >> 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)); > > > > This chunk does not appear to belong to this patch. > > Should not this helper be made a 'static inline' before using it else where ? Probably yes, but it is not kvm s390-specific change. I guess, you wanted to make it together or as a follow-up to this one? https://lore.kernel.org/all/20221124131641.1523772-1-anshuman.khandual@arm.com/
On 11/28/22 12:43, Alexander Gordeev wrote: > On Mon, Nov 28, 2022 at 12:01:06PM +0530, Anshuman Khandual wrote: >>>> 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)); >>> >>> This chunk does not appear to belong to this patch. >> >> Should not this helper be made a 'static inline' before using it else where ? > > Probably yes, but it is not kvm s390-specific change. Right, just that the s390 change here is the first instance where this helper is being used outside the header, hence kept them together. > > I guess, you wanted to make it together or as a follow-up to this one? > https://lore.kernel.org/all/20221124131641.1523772-1-anshuman.khandual@arm.com/ > Unless too much trouble, could we just keep it here as proposed.
On Mon, Nov 28, 2022 at 01:13:45PM +0530, Anshuman Khandual wrote: > >>>> 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)); > >>> > >>> This chunk does not appear to belong to this patch. > >> > >> Should not this helper be made a 'static inline' before using it else where ? > > > > Probably yes, but it is not kvm s390-specific change. > > Right, just that the s390 change here is the first instance where this helper > is being used outside the header, hence kept them together. > > > > > I guess, you wanted to make it together or as a follow-up to this one? > > https://lore.kernel.org/all/20221124131641.1523772-1-anshuman.khandual@arm.com/ > > > Unless too much trouble, could we just keep it here as proposed. For s390 part: Acked-by: Alexander Gordeev <agordeev@linux.ibm.com> Thanks!
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));