All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm: cma: print cma name as well in cma_alloc debug
@ 2023-07-06 18:27 Pintu Kumar
  2023-07-06 18:33 ` [PATCH v2] " Pintu Kumar
  0 siblings, 1 reply; 11+ messages in thread
From: Pintu Kumar @ 2023-07-06 18:27 UTC (permalink / raw)
  To: linux-kernel, akpm, linux-mm; +Cc: quic_pintu, pintu.ping

CMA allocation can happen either from global cma or from
dedicated cma region.

Thus it is helpful to print cma name as well during initial
debugging to confirm cma regions were getting initialized or not.

Signed-off-by: Pintu Kumar <quic_pintu@quicinc.com>
Signed-off-by: Pintu Agarwal <pintu.ping@gmail.com>
---
 mm/cma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/cma.c b/mm/cma.c
index a4cfe99..96718b53 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -436,8 +436,8 @@ 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,
-		 count, align);
+	pr_info("%s(cma %p, name: %s, count %lu, align %d)\n", __func__,
+		(void *)cma, cma->name, count, align);
 
 	if (!count)
 		goto out;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2] mm: cma: print cma name as well in cma_alloc debug
  2023-07-06 18:27 [PATCH] mm: cma: print cma name as well in cma_alloc debug Pintu Kumar
@ 2023-07-06 18:33 ` Pintu Kumar
  2023-07-07 10:27   ` Anshuman Khandual
  0 siblings, 1 reply; 11+ messages in thread
From: Pintu Kumar @ 2023-07-06 18:33 UTC (permalink / raw)
  To: linux-kernel, akpm, linux-mm; +Cc: quic_pintu, pintu.ping

CMA allocation can happen either from global cma or from
dedicated cma region.

Thus it is helpful to print cma name as well during initial
debugging to confirm cma regions were getting initialized or not.

Signed-off-by: Pintu Kumar <quic_pintu@quicinc.com>
Signed-off-by: Pintu Agarwal <pintu.ping@gmail.com>
---
 mm/cma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/cma.c b/mm/cma.c
index a4cfe99..4880f72 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -436,8 +436,8 @@ 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,
-		 count, align);
+	pr_debug("%s(cma %p, name: %s, count %lu, align %d)\n", __func__,
+		(void *)cma, cma->name, count, align);
 
 	if (!count)
 		goto out;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] mm: cma: print cma name as well in cma_alloc debug
  2023-07-06 18:33 ` [PATCH v2] " Pintu Kumar
@ 2023-07-07 10:27   ` Anshuman Khandual
  2023-07-07 12:46     ` Matthew Wilcox
  0 siblings, 1 reply; 11+ messages in thread
From: Anshuman Khandual @ 2023-07-07 10:27 UTC (permalink / raw)
  To: Pintu Kumar, linux-kernel, akpm, linux-mm; +Cc: pintu.ping



On 7/7/23 00:03, Pintu Kumar wrote:
> CMA allocation can happen either from global cma or from
> dedicated cma region.
> 
> Thus it is helpful to print cma name as well during initial
> debugging to confirm cma regions were getting initialized or not.
> 
> Signed-off-by: Pintu Kumar <quic_pintu@quicinc.com>
> Signed-off-by: Pintu Agarwal <pintu.ping@gmail.com>
> ---
>  mm/cma.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/cma.c b/mm/cma.c
> index a4cfe99..4880f72 100644
> --- a/mm/cma.c
> +++ b/mm/cma.c
> @@ -436,8 +436,8 @@ 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,
> -		 count, align);
> +	pr_debug("%s(cma %p, name: %s, count %lu, align %d)\n", __func__,
> +		(void *)cma, cma->name, count, align);
>  
>  	if (!count)
>  		goto out;

LGTM, cma->name is an identifying attribute for the region for which the allocation
request was made. But how about using cma_get_name() helper instead ? Very few call
sites have been using the helper.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] mm: cma: print cma name as well in cma_alloc debug
  2023-07-07 10:27   ` Anshuman Khandual
@ 2023-07-07 12:46     ` Matthew Wilcox
  2023-07-07 14:06       ` Pintu Agarwal
  0 siblings, 1 reply; 11+ messages in thread
From: Matthew Wilcox @ 2023-07-07 12:46 UTC (permalink / raw)
  To: Anshuman Khandual; +Cc: Pintu Kumar, linux-kernel, akpm, linux-mm, pintu.ping

On Fri, Jul 07, 2023 at 03:57:42PM +0530, Anshuman Khandual wrote:
> LGTM, cma->name is an identifying attribute for the region for which the allocation
> request was made. But how about using cma_get_name() helper instead ? Very few call
> sites have been using the helper.

It's not really a "helper", is it?  The function name is longer than
its implementation.

cma_get_name(cma)
vs
cma->name

Plus there's the usual question about whether a "got" name needs to be
"put" (does it grab a refcount?)

I think it's useful that this function exists since it lets us not expose
struct cma outside of mm/, but it really should be called cma_name()
and I don't think we should be encouraging its use within cma.c.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] mm: cma: print cma name as well in cma_alloc debug
  2023-07-07 12:46     ` Matthew Wilcox
@ 2023-07-07 14:06       ` Pintu Agarwal
  2023-07-07 14:09         ` Matthew Wilcox
  0 siblings, 1 reply; 11+ messages in thread
From: Pintu Agarwal @ 2023-07-07 14:06 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Anshuman Khandual, Pintu Kumar, linux-kernel, akpm, linux-mm

On Fri, 7 Jul 2023 at 18:16, Matthew Wilcox <willy@infradead.org> wrote:
>
> On Fri, Jul 07, 2023 at 03:57:42PM +0530, Anshuman Khandual wrote:
> > LGTM, cma->name is an identifying attribute for the region for which the allocation
> > request was made. But how about using cma_get_name() helper instead ? Very few call
> > sites have been using the helper.
>
> It's not really a "helper", is it?  The function name is longer than
> its implementation.
>
> cma_get_name(cma)
> vs
> cma->name
>
> Plus there's the usual question about whether a "got" name needs to be
> "put" (does it grab a refcount?)
>
> I think it's useful that this function exists since it lets us not expose
> struct cma outside of mm/, but it really should be called cma_name()
> and I don't think we should be encouraging its use within cma.c.

Also, cma_get_name() is a trivial assignment.
And in one of the previous patches we avoided function calls with
trivial assignments.
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/kernel/dma/contiguous.c?h=next-20230705&id=5af638931eb374aa0894d8343cee72f50307ef20
dma-contiguous: remove dev_set_cma_area

One more question from here:
pr_debug("%s(cma %p, name: %s, count %lu, align %d)\n", __func__,
                (void *)cma, cma->name, count, align);

Do we really need this "cma %p" printing ?
I hardly check it and simply rely on name and count.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] mm: cma: print cma name as well in cma_alloc debug
  2023-07-07 14:06       ` Pintu Agarwal
@ 2023-07-07 14:09         ` Matthew Wilcox
  2023-07-07 14:16           ` Pintu Agarwal
  0 siblings, 1 reply; 11+ messages in thread
From: Matthew Wilcox @ 2023-07-07 14:09 UTC (permalink / raw)
  To: Pintu Agarwal
  Cc: Anshuman Khandual, Pintu Kumar, linux-kernel, akpm, linux-mm

On Fri, Jul 07, 2023 at 07:36:20PM +0530, Pintu Agarwal wrote:
> On Fri, 7 Jul 2023 at 18:16, Matthew Wilcox <willy@infradead.org> wrote:
> >
> > On Fri, Jul 07, 2023 at 03:57:42PM +0530, Anshuman Khandual wrote:
> > > LGTM, cma->name is an identifying attribute for the region for which the allocation
> > > request was made. But how about using cma_get_name() helper instead ? Very few call
> > > sites have been using the helper.
> >
> > It's not really a "helper", is it?  The function name is longer than
> > its implementation.
> >
> > cma_get_name(cma)
> > vs
> > cma->name
> >
> > Plus there's the usual question about whether a "got" name needs to be
> > "put" (does it grab a refcount?)
> >
> > I think it's useful that this function exists since it lets us not expose
> > struct cma outside of mm/, but it really should be called cma_name()
> > and I don't think we should be encouraging its use within cma.c.
> 
> Also, cma_get_name() is a trivial assignment.
> And in one of the previous patches we avoided function calls with
> trivial assignments.
> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/kernel/dma/contiguous.c?h=next-20230705&id=5af638931eb374aa0894d8343cee72f50307ef20
> dma-contiguous: remove dev_set_cma_area
> 
> One more question from here:
> pr_debug("%s(cma %p, name: %s, count %lu, align %d)\n", __func__,
>                 (void *)cma, cma->name, count, align);
> 
> Do we really need this "cma %p" printing ?
> I hardly check it and simply rely on name and count.

Printing pointers is almost always a bad idea.  Printing the base_pfn
might be a good idea to distinguish CMAs which happen to have the
same name?


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] mm: cma: print cma name as well in cma_alloc debug
  2023-07-07 14:09         ` Matthew Wilcox
@ 2023-07-07 14:16           ` Pintu Agarwal
  2023-07-07 14:22             ` Matthew Wilcox
  0 siblings, 1 reply; 11+ messages in thread
From: Pintu Agarwal @ 2023-07-07 14:16 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Anshuman Khandual, Pintu Kumar, linux-kernel, akpm, linux-mm

On Fri, 7 Jul 2023 at 19:40, Matthew Wilcox <willy@infradead.org> wrote:
>
> On Fri, Jul 07, 2023 at 07:36:20PM +0530, Pintu Agarwal wrote:
> > On Fri, 7 Jul 2023 at 18:16, Matthew Wilcox <willy@infradead.org> wrote:
> > >
> > > On Fri, Jul 07, 2023 at 03:57:42PM +0530, Anshuman Khandual wrote:
> > > > LGTM, cma->name is an identifying attribute for the region for which the allocation
> > > > request was made. But how about using cma_get_name() helper instead ? Very few call
> > > > sites have been using the helper.
> > >
> > > It's not really a "helper", is it?  The function name is longer than
> > > its implementation.
> > >
> > > cma_get_name(cma)
> > > vs
> > > cma->name
> > >
> > > Plus there's the usual question about whether a "got" name needs to be
> > > "put" (does it grab a refcount?)
> > >
> > > I think it's useful that this function exists since it lets us not expose
> > > struct cma outside of mm/, but it really should be called cma_name()
> > > and I don't think we should be encouraging its use within cma.c.
> >
> > Also, cma_get_name() is a trivial assignment.
> > And in one of the previous patches we avoided function calls with
> > trivial assignments.
> > https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/kernel/dma/contiguous.c?h=next-20230705&id=5af638931eb374aa0894d8343cee72f50307ef20
> > dma-contiguous: remove dev_set_cma_area
> >
> > One more question from here:
> > pr_debug("%s(cma %p, name: %s, count %lu, align %d)\n", __func__,
> >                 (void *)cma, cma->name, count, align);
> >
> > Do we really need this "cma %p" printing ?
> > I hardly check it and simply rely on name and count.
>
> Printing pointers is almost always a bad idea.  Printing the base_pfn
> might be a good idea to distinguish CMAs which happen to have the
> same name?
>
No there is no name there, it's just a ptrval
cma: cma_alloc(cma (ptrval), name: reserved, count 64, align 6)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] mm: cma: print cma name as well in cma_alloc debug
  2023-07-07 14:16           ` Pintu Agarwal
@ 2023-07-07 14:22             ` Matthew Wilcox
  2023-07-07 14:33               ` Pintu Agarwal
  0 siblings, 1 reply; 11+ messages in thread
From: Matthew Wilcox @ 2023-07-07 14:22 UTC (permalink / raw)
  To: Pintu Agarwal
  Cc: Anshuman Khandual, Pintu Kumar, linux-kernel, akpm, linux-mm

On Fri, Jul 07, 2023 at 07:46:31PM +0530, Pintu Agarwal wrote:
> On Fri, 7 Jul 2023 at 19:40, Matthew Wilcox <willy@infradead.org> wrote:
> > > One more question from here:
> > > pr_debug("%s(cma %p, name: %s, count %lu, align %d)\n", __func__,
> > >                 (void *)cma, cma->name, count, align);
> > >
> > > Do we really need this "cma %p" printing ?
> > > I hardly check it and simply rely on name and count.
> >
> > Printing pointers is almost always a bad idea.  Printing the base_pfn
> > might be a good idea to distinguish CMAs which happen to have the
> > same name?
> >
> No there is no name there, it's just a ptrval
> cma: cma_alloc(cma (ptrval), name: reserved, count 64, align 6)

You misunderstand me.  I don't know how CMAs get their name.  Is it not
possible for two CMAs to have the same name as each other?


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] mm: cma: print cma name as well in cma_alloc debug
  2023-07-07 14:22             ` Matthew Wilcox
@ 2023-07-07 14:33               ` Pintu Agarwal
  2023-07-08  6:52                 ` Pintu Agarwal
  0 siblings, 1 reply; 11+ messages in thread
From: Pintu Agarwal @ 2023-07-07 14:33 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Anshuman Khandual, Pintu Kumar, linux-kernel, akpm, linux-mm

On Fri, 7 Jul 2023 at 19:52, Matthew Wilcox <willy@infradead.org> wrote:
>
> On Fri, Jul 07, 2023 at 07:46:31PM +0530, Pintu Agarwal wrote:
> > On Fri, 7 Jul 2023 at 19:40, Matthew Wilcox <willy@infradead.org> wrote:
> > > > One more question from here:
> > > > pr_debug("%s(cma %p, name: %s, count %lu, align %d)\n", __func__,
> > > >                 (void *)cma, cma->name, count, align);
> > > >
> > > > Do we really need this "cma %p" printing ?
> > > > I hardly check it and simply rely on name and count.
> > >
> > > Printing pointers is almost always a bad idea.  Printing the base_pfn
> > > might be a good idea to distinguish CMAs which happen to have the
> > > same name?
> > >
> > No there is no name there, it's just a ptrval
> > cma: cma_alloc(cma (ptrval), name: reserved, count 64, align 6)
>
> You misunderstand me.  I don't know how CMAs get their name.  Is it not
> possible for two CMAs to have the same name as each other?
>
Oh yah that is possible, for example multiple players can use the same
global cma region.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] mm: cma: print cma name as well in cma_alloc debug
  2023-07-07 14:33               ` Pintu Agarwal
@ 2023-07-08  6:52                 ` Pintu Agarwal
  2023-07-12 14:02                   ` Pintu Agarwal
  0 siblings, 1 reply; 11+ messages in thread
From: Pintu Agarwal @ 2023-07-08  6:52 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Anshuman Khandual, Pintu Kumar, linux-kernel, akpm, linux-mm

On Fri, 7 Jul 2023 at 20:03, Pintu Agarwal <pintu.ping@gmail.com> wrote:
>
> On Fri, 7 Jul 2023 at 19:52, Matthew Wilcox <willy@infradead.org> wrote:
> >
> > On Fri, Jul 07, 2023 at 07:46:31PM +0530, Pintu Agarwal wrote:
> > > On Fri, 7 Jul 2023 at 19:40, Matthew Wilcox <willy@infradead.org> wrote:
> > > > > One more question from here:
> > > > > pr_debug("%s(cma %p, name: %s, count %lu, align %d)\n", __func__,
> > > > >                 (void *)cma, cma->name, count, align);
> > > > >
> > > > > Do we really need this "cma %p" printing ?
> > > > > I hardly check it and simply rely on name and count.
> > > >
> > > > Printing pointers is almost always a bad idea.  Printing the base_pfn
> > > > might be a good idea to distinguish CMAs which happen to have the
> > > > same name?
> > > >
> > > No there is no name there, it's just a ptrval
> > > cma: cma_alloc(cma (ptrval), name: reserved, count 64, align 6)
> >
> > You misunderstand me.  I don't know how CMAs get their name.  Is it not
> > possible for two CMAs to have the same name as each other?
> >
> Oh yah that is possible, for example multiple players can use the same
> global cma region.

Yes, I think it's a good idea to include base_pfn instead of printing pointers.
Let's complete the cma->name inclusion first.
Later I will check about base_pfn and push in another patch.
Thanks

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] mm: cma: print cma name as well in cma_alloc debug
  2023-07-08  6:52                 ` Pintu Agarwal
@ 2023-07-12 14:02                   ` Pintu Agarwal
  0 siblings, 0 replies; 11+ messages in thread
From: Pintu Agarwal @ 2023-07-12 14:02 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Anshuman Khandual, Pintu Kumar, linux-kernel, akpm, linux-mm

On Sat, 8 Jul 2023 at 12:22, Pintu Agarwal <pintu.ping@gmail.com> wrote:
>
> On Fri, 7 Jul 2023 at 20:03, Pintu Agarwal <pintu.ping@gmail.com> wrote:
> >
> > On Fri, 7 Jul 2023 at 19:52, Matthew Wilcox <willy@infradead.org> wrote:
> > >
> > > On Fri, Jul 07, 2023 at 07:46:31PM +0530, Pintu Agarwal wrote:
> > > > On Fri, 7 Jul 2023 at 19:40, Matthew Wilcox <willy@infradead.org> wrote:
> > > > > > One more question from here:
> > > > > > pr_debug("%s(cma %p, name: %s, count %lu, align %d)\n", __func__,
> > > > > >                 (void *)cma, cma->name, count, align);
> > > > > >
> > > > > > Do we really need this "cma %p" printing ?
> > > > > > I hardly check it and simply rely on name and count.
> > > > >
> > > > > Printing pointers is almost always a bad idea.  Printing the base_pfn
> > > > > might be a good idea to distinguish CMAs which happen to have the
> > > > > same name?
> > > > >
> > > > No there is no name there, it's just a ptrval
> > > > cma: cma_alloc(cma (ptrval), name: reserved, count 64, align 6)
> > >
> > > You misunderstand me.  I don't know how CMAs get their name.  Is it not
> > > possible for two CMAs to have the same name as each other?
> > >
> > Oh yah that is possible, for example multiple players can use the same
> > global cma region.
>
> Yes, I think it's a good idea to include base_pfn instead of printing pointers.
> Let's complete the cma->name inclusion first.
> Later I will check about base_pfn and push in another patch.
> Thanks

I hope we are good with printing cma->name here ?

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-07-12 14:03 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-06 18:27 [PATCH] mm: cma: print cma name as well in cma_alloc debug Pintu Kumar
2023-07-06 18:33 ` [PATCH v2] " Pintu Kumar
2023-07-07 10:27   ` Anshuman Khandual
2023-07-07 12:46     ` Matthew Wilcox
2023-07-07 14:06       ` Pintu Agarwal
2023-07-07 14:09         ` Matthew Wilcox
2023-07-07 14:16           ` Pintu Agarwal
2023-07-07 14:22             ` Matthew Wilcox
2023-07-07 14:33               ` Pintu Agarwal
2023-07-08  6:52                 ` Pintu Agarwal
2023-07-12 14:02                   ` Pintu Agarwal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.