Message ID | 1681788789-19679-1-git-send-email-zhaoyang.huang@unisoc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2558828vqo; Mon, 17 Apr 2023 20:39:52 -0700 (PDT) X-Google-Smtp-Source: AKy350b2GGW49yZ1EA4Q6hSLiYH1xhi20ONhG4YPlko2Pn1ni16hJWnjuiOCFFoonTe0gmG2SnZo X-Received: by 2002:a05:6a20:4413:b0:ee:b102:2efd with SMTP id ce19-20020a056a20441300b000eeb1022efdmr13789408pzb.3.1681789192690; Mon, 17 Apr 2023 20:39:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681789192; cv=none; d=google.com; s=arc-20160816; b=CBPHUxEUqwNhm3BleNzx99ZhnLrLqNv+rgdQ5dO3nDHkg0l5u1UDD4Gq0W29mHf0P0 BHHrGlj9nSBpsKFjRT9eYB8t7ej+GuXoq5SXC7PzHXA4I9liq0vwT9trW8pYP1YeA0a7 qc6qu1aN9eSy9o+7UHpR4QWjHMOkeXLEqQokoRO8Arj9VpPTcb1k5w7OA6jQXI0raea7 +h2fm7M/zvnubBWqcFuP27e8Ou7N6f9dSHEUnJ3CL1gD6bjGQnUn4XrpSuw6FDVV8y8r Y04tC7ubLJvpOyF20xKCRudqBvXmhg5ZB68LsEt9zG9+ar0EoUerXcYZibJvqNQZLaxt KgYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:to:from; bh=4pc1NWmXDTjQzs2HiIEI7k1Bis+2lgG7wExwVZ8DsQ8=; b=pAbKX4w3HbXYjvh+M6+sHxX8ZXgi7mCHWtvDeZmg6wtbeL958/OEUKlZmhHeI60Sa7 EBZ+iVORxEMM/zaZL3saD58DVSJ48J5JD363ZRSyKRonFu51HvxpYOjnGdXNt7gfwKPt 9twK6avHGIlYhMqxE0c7GsLYCzXuVwuhiUwScrq0l3w9hbZnNLi7oF24qJk5hrnhK6dS xKstl9sLY39Qb3ntEhlWwmyELAIXLDEVcFF3agnhqhVxn5egbMB1fP/GDAsKR1LRusJN waF9qe4/5ZMN4QoYRwhLtTDq+oPx+fkRbUGoR8OfuW9ZA4pcPlcGL1XVRXh8UkHDgkv8 ifQQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m17-20020a656a11000000b0050f74bf6b3asi15190237pgu.700.2023.04.17.20.39.37; Mon, 17 Apr 2023 20:39:52 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230053AbjDRDeO (ORCPT <rfc822;leviz.kernel.dev@gmail.com> + 99 others); Mon, 17 Apr 2023 23:34:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229662AbjDRDeN (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 17 Apr 2023 23:34:13 -0400 Received: from SHSQR01.spreadtrum.com (unknown [222.66.158.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C16B81FCA for <linux-kernel@vger.kernel.org>; Mon, 17 Apr 2023 20:34:09 -0700 (PDT) Received: from SHSend.spreadtrum.com (bjmbx01.spreadtrum.com [10.0.64.7]) by SHSQR01.spreadtrum.com with ESMTP id 33I3XRlX088878; Tue, 18 Apr 2023 11:33:27 +0800 (+08) (envelope-from zhaoyang.huang@unisoc.com) Received: from bj03382pcu.spreadtrum.com (10.0.74.65) by BJMBX01.spreadtrum.com (10.0.64.7) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Tue, 18 Apr 2023 11:33:23 +0800 From: "zhaoyang.huang" <zhaoyang.huang@unisoc.com> To: Andrew Morton <akpm@linux-foundation.org>, Minchan Kim <minchan@kernel.org>, Joonsoo Kim <iamjoonsoo.kim@lge.com>, <linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>, Zhaoyang Huang <huangzhaoyang@gmail.com>, <ke.wang@unisoc.com> Subject: [PATCH] mm: fix printk format within cma Date: Tue, 18 Apr 2023 11:33:09 +0800 Message-ID: <1681788789-19679-1-git-send-email-zhaoyang.huang@unisoc.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.0.74.65] X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX01.spreadtrum.com (10.0.64.7) X-MAIL: SHSQR01.spreadtrum.com 33I3XRlX088878 X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,HEXHASH_WORD, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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?1763483784234848461?= X-GMAIL-MSGID: =?utf-8?q?1763483784234848461?= |
Series |
mm: fix printk format within cma
|
|
Commit Message
zhaoyang.huang
April 18, 2023, 3:33 a.m. UTC
From: Zhaoyang Huang <zhaoyang.huang@unisoc.com> cma and page pointer printed via %p are hash value which make debug to be hard. change them to %px. [63321.482751] [c7] cma: cma_alloc(): memory range at 000000000b5e462c is busy, retrying [63321.482786] [c7] cma: cma_alloc(): memory range at 000000000f7d6fae is busy, retrying [63321.482823] [c7] cma: cma_alloc(): memory range at 00000000e653b59b is busy, retrying [63322.378890] [c7] cma: cma_release(page 00000000dd53cf48) [63322.378913] [c7] cma: cma_release(page 00000000315f703d) [63322.378925] [c7] cma: cma_release(page 00000000791e3a5f) Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com> --- mm/cma.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Comments
On Tue, Apr 18, 2023 at 11:33:09AM +0800, zhaoyang.huang wrote: > cma and page pointer printed via %p are hash value which make debug to be hard. > change them to %px. Why does printing the page pointer make any sense at all? Surely the PFN makes much more sense. > [63321.482751] [c7] cma: cma_alloc(): memory range at 000000000b5e462c is busy, retrying > [63321.482786] [c7] cma: cma_alloc(): memory range at 000000000f7d6fae is busy, retrying > [63321.482823] [c7] cma: cma_alloc(): memory range at 00000000e653b59b is busy, retrying > [63322.378890] [c7] cma: cma_release(page 00000000dd53cf48) > [63322.378913] [c7] cma: cma_release(page 00000000315f703d) > [63322.378925] [c7] cma: cma_release(page 00000000791e3a5f) > > Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com> > --- > mm/cma.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/mm/cma.c b/mm/cma.c > index 4a978e0..dfe9813 100644 > --- a/mm/cma.c > +++ b/mm/cma.c > @@ -435,7 +435,7 @@ struct page *cma_alloc(struct cma *cma, unsigned long count, > if (!cma || !cma->count || !cma->bitmap) > goto out; > > - pr_debug("%s(cma %p, count %lu, align %d)\n", __func__, (void *)cma, > + pr_debug("%s(cma %px, count %lu, align %d)\n", __func__, (void *)cma, > count, align); > > if (!count) > @@ -534,7 +534,7 @@ bool cma_pages_valid(struct cma *cma, const struct page *pages, > pfn = page_to_pfn(pages); > > if (pfn < cma->base_pfn || pfn >= cma->base_pfn + cma->count) { > - pr_debug("%s(page %p, count %lu)\n", __func__, > + pr_debug("%s(page %px, count %lu)\n", __func__, > (void *)pages, count); > return false; > } > @@ -560,7 +560,7 @@ bool cma_release(struct cma *cma, const struct page *pages, > if (!cma_pages_valid(cma, pages, count)) > return false; > > - pr_debug("%s(page %p, count %lu)\n", __func__, (void *)pages, count); > + pr_debug("%s(page %px, count %lu)\n", __func__, (void *)pages, count); > > pfn = page_to_pfn(pages); > > -- > 1.9.1 > >
On Tue, Apr 18, 2023 at 11:38 AM Matthew Wilcox <willy@infradead.org> wrote: > > On Tue, Apr 18, 2023 at 11:33:09AM +0800, zhaoyang.huang wrote: > > cma and page pointer printed via %p are hash value which make debug to be hard. > > change them to %px. > > Why does printing the page pointer make any sense at all? Surely the > PFN makes much more sense. either pfn or a correct page pointer makes sense for debugging, while page could be more safe than pfn which expose the paddr directly > > > [63321.482751] [c7] cma: cma_alloc(): memory range at 000000000b5e462c is busy, retrying > > [63321.482786] [c7] cma: cma_alloc(): memory range at 000000000f7d6fae is busy, retrying > > [63321.482823] [c7] cma: cma_alloc(): memory range at 00000000e653b59b is busy, retrying > > [63322.378890] [c7] cma: cma_release(page 00000000dd53cf48) > > [63322.378913] [c7] cma: cma_release(page 00000000315f703d) > > [63322.378925] [c7] cma: cma_release(page 00000000791e3a5f) > > > > Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com> > > --- > > mm/cma.c | 6 +++--- > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > diff --git a/mm/cma.c b/mm/cma.c > > index 4a978e0..dfe9813 100644 > > --- a/mm/cma.c > > +++ b/mm/cma.c > > @@ -435,7 +435,7 @@ struct page *cma_alloc(struct cma *cma, unsigned long count, > > if (!cma || !cma->count || !cma->bitmap) > > goto out; > > > > - pr_debug("%s(cma %p, count %lu, align %d)\n", __func__, (void *)cma, > > + pr_debug("%s(cma %px, count %lu, align %d)\n", __func__, (void *)cma, > > count, align); > > > > if (!count) > > @@ -534,7 +534,7 @@ bool cma_pages_valid(struct cma *cma, const struct page *pages, > > pfn = page_to_pfn(pages); > > > > if (pfn < cma->base_pfn || pfn >= cma->base_pfn + cma->count) { > > - pr_debug("%s(page %p, count %lu)\n", __func__, > > + pr_debug("%s(page %px, count %lu)\n", __func__, > > (void *)pages, count); > > return false; > > } > > @@ -560,7 +560,7 @@ bool cma_release(struct cma *cma, const struct page *pages, > > if (!cma_pages_valid(cma, pages, count)) > > return false; > > > > - pr_debug("%s(page %p, count %lu)\n", __func__, (void *)pages, count); > > + pr_debug("%s(page %px, count %lu)\n", __func__, (void *)pages, count); > > > > pfn = page_to_pfn(pages); > > > > -- > > 1.9.1 > > > >
Zhaoyang Huang <huangzhaoyang@gmail.com> writes: > On Tue, Apr 18, 2023 at 11:38 AM Matthew Wilcox <willy@infradead.org> wrote: >> >> On Tue, Apr 18, 2023 at 11:33:09AM +0800, zhaoyang.huang wrote: >> > cma and page pointer printed via %p are hash value which make debug to be hard. >> > change them to %px. >> >> Why does printing the page pointer make any sense at all? Surely the >> PFN makes much more sense. > either pfn or a correct page pointer makes sense for debugging, while > page could be more safe than pfn which expose the paddr directly You can specify "no_hash_pointers" in kernel command line to print pointer value for debug. IIUC, this take care of both security and debuggability. Best Regards, Huang, Ying >> >> > [63321.482751] [c7] cma: cma_alloc(): memory range at 000000000b5e462c is busy, retrying >> > [63321.482786] [c7] cma: cma_alloc(): memory range at 000000000f7d6fae is busy, retrying >> > [63321.482823] [c7] cma: cma_alloc(): memory range at 00000000e653b59b is busy, retrying >> > [63322.378890] [c7] cma: cma_release(page 00000000dd53cf48) >> > [63322.378913] [c7] cma: cma_release(page 00000000315f703d) >> > [63322.378925] [c7] cma: cma_release(page 00000000791e3a5f) >> > >> > Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com> >> > --- >> > mm/cma.c | 6 +++--- >> > 1 file changed, 3 insertions(+), 3 deletions(-) >> > >> > diff --git a/mm/cma.c b/mm/cma.c >> > index 4a978e0..dfe9813 100644 >> > --- a/mm/cma.c >> > +++ b/mm/cma.c >> > @@ -435,7 +435,7 @@ struct page *cma_alloc(struct cma *cma, unsigned long count, >> > if (!cma || !cma->count || !cma->bitmap) >> > goto out; >> > >> > - pr_debug("%s(cma %p, count %lu, align %d)\n", __func__, (void *)cma, >> > + pr_debug("%s(cma %px, count %lu, align %d)\n", __func__, (void *)cma, >> > count, align); >> > >> > if (!count) >> > @@ -534,7 +534,7 @@ bool cma_pages_valid(struct cma *cma, const struct page *pages, >> > pfn = page_to_pfn(pages); >> > >> > if (pfn < cma->base_pfn || pfn >= cma->base_pfn + cma->count) { >> > - pr_debug("%s(page %p, count %lu)\n", __func__, >> > + pr_debug("%s(page %px, count %lu)\n", __func__, >> > (void *)pages, count); >> > return false; >> > } >> > @@ -560,7 +560,7 @@ bool cma_release(struct cma *cma, const struct page *pages, >> > if (!cma_pages_valid(cma, pages, count)) >> > return false; >> > >> > - pr_debug("%s(page %p, count %lu)\n", __func__, (void *)pages, count); >> > + pr_debug("%s(page %px, count %lu)\n", __func__, (void *)pages, count); >> > >> > pfn = page_to_pfn(pages); >> > >> > -- >> > 1.9.1 >> > >> >
On Tue, 18 Apr 2023 04:38:24 +0100 Matthew Wilcox <willy@infradead.org> wrote: > On Tue, Apr 18, 2023 at 11:33:09AM +0800, zhaoyang.huang wrote: > > cma and page pointer printed via %p are hash value which make debug to be hard. > > change them to %px. > > Why does printing the page pointer make any sense at all? Surely the > PFN makes much more sense. I suppose one could correlate a particular hashed pointer with other debug output, see "ah, that's the same page". In which case one doesn't really care whether or not the address is hashed - it's just a cookie. This sounds thin. I doubt if a lot of thought went into the printk. If the page pointer isn't useful then how about we simply remove it from the message?
On Tue, Apr 18, 2023 at 12:33:38PM -0700, Andrew Morton wrote: > On Tue, 18 Apr 2023 04:38:24 +0100 Matthew Wilcox <willy@infradead.org> wrote: > > > On Tue, Apr 18, 2023 at 11:33:09AM +0800, zhaoyang.huang wrote: > > > cma and page pointer printed via %p are hash value which make debug to be hard. > > > change them to %px. > > > > Why does printing the page pointer make any sense at all? Surely the > > PFN makes much more sense. > > I suppose one could correlate a particular hashed pointer with other > debug output, see "ah, that's the same page". In which case one > doesn't really care whether or not the address is hashed - it's just a > cookie. This sounds thin. > > I doubt if a lot of thought went into the printk. If the page pointer > isn't useful then how about we simply remove it from the message? If something about it weren't useful, I don't think we'd be seeing a patch to transform it from a hashed pointer to an unhashed pointer? I'm pretty sure the PFN is the real information that's wanted here, since you can look at the hardware RAM layout to determine why that's not eligible.
diff --git a/mm/cma.c b/mm/cma.c index 4a978e0..dfe9813 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -435,7 +435,7 @@ struct page *cma_alloc(struct cma *cma, unsigned long count, if (!cma || !cma->count || !cma->bitmap) goto out; - pr_debug("%s(cma %p, count %lu, align %d)\n", __func__, (void *)cma, + pr_debug("%s(cma %px, count %lu, align %d)\n", __func__, (void *)cma, count, align); if (!count) @@ -534,7 +534,7 @@ bool cma_pages_valid(struct cma *cma, const struct page *pages, pfn = page_to_pfn(pages); if (pfn < cma->base_pfn || pfn >= cma->base_pfn + cma->count) { - pr_debug("%s(page %p, count %lu)\n", __func__, + pr_debug("%s(page %px, count %lu)\n", __func__, (void *)pages, count); return false; } @@ -560,7 +560,7 @@ bool cma_release(struct cma *cma, const struct page *pages, if (!cma_pages_valid(cma, pages, count)) return false; - pr_debug("%s(page %p, count %lu)\n", __func__, (void *)pages, count); + pr_debug("%s(page %px, count %lu)\n", __func__, (void *)pages, count); pfn = page_to_pfn(pages);