mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] x86/resctrl: Fix return code in mkdir_rdt_prepare()
@ 2021-09-24  8:17 Shaopeng Tan
  2021-09-24 18:53 ` Reinette Chatre
  0 siblings, 1 reply; 3+ messages in thread
From: Shaopeng Tan @ 2021-09-24  8:17 UTC (permalink / raw)
  To: Fenghua Yu, Reinette Chatre, tan.shaopeng
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
	H. Peter Anvin, linux-kernel

When kzalloc fails, we should return ENOMEM instead of ENOSPC.

Signed-off-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
---
Hello,

I just noticed this when I read the code.

Thanks,

 arch/x86/kernel/cpu/resctrl/rdtgroup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index b57b3db9a6a7..a92d047476f6 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -2854,7 +2854,7 @@ static int mkdir_rdt_prepare(struct kernfs_node *parent_kn,
 	/* allocate the rdtgroup. */
 	rdtgrp = kzalloc(sizeof(*rdtgrp), GFP_KERNEL);
 	if (!rdtgrp) {
-		ret = -ENOSPC;
+		ret = -ENOMEM;
 		rdt_last_cmd_puts("Kernel out of memory\n");
 		goto out_unlock;
 	}
-- 
2.27.0


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

* Re: [PATCH] x86/resctrl: Fix return code in mkdir_rdt_prepare()
  2021-09-24  8:17 [PATCH] x86/resctrl: Fix return code in mkdir_rdt_prepare() Shaopeng Tan
@ 2021-09-24 18:53 ` Reinette Chatre
  2021-09-28  4:44   ` tan.shaopeng
  0 siblings, 1 reply; 3+ messages in thread
From: Reinette Chatre @ 2021-09-24 18:53 UTC (permalink / raw)
  To: Shaopeng Tan, Fenghua Yu
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
	H. Peter Anvin, linux-kernel

Hi Shaopeng Tan,

On 9/24/2021 1:17 AM, Shaopeng Tan wrote:
> When kzalloc fails, we should return ENOMEM instead of ENOSPC.
> 
> Signed-off-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
> ---
> Hello,
> 
> I just noticed this when I read the code.
> 
> Thanks,
> 
>   arch/x86/kernel/cpu/resctrl/rdtgroup.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> index b57b3db9a6a7..a92d047476f6 100644
> --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> @@ -2854,7 +2854,7 @@ static int mkdir_rdt_prepare(struct kernfs_node *parent_kn,
>   	/* allocate the rdtgroup. */
>   	rdtgrp = kzalloc(sizeof(*rdtgrp), GFP_KERNEL);
>   	if (!rdtgrp) {
> -		ret = -ENOSPC;
> +		ret = -ENOMEM;
>   		rdt_last_cmd_puts("Kernel out of memory\n");
>   		goto out_unlock;
>   	}
> 

I do not know the original motivation for using ENOSPC but from what I 
can tell this error is propagated all the way to user space. This change 
thus has the consequence that any interface built on top of resctrl 
could be impacted.

Is there a specific issue that you are aiming to fix here?

Reinette

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

* RE: [PATCH] x86/resctrl: Fix return code in mkdir_rdt_prepare()
  2021-09-24 18:53 ` Reinette Chatre
@ 2021-09-28  4:44   ` tan.shaopeng
  0 siblings, 0 replies; 3+ messages in thread
From: tan.shaopeng @ 2021-09-28  4:44 UTC (permalink / raw)
  To: 'Reinette Chatre', Fenghua Yu
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
	H. Peter Anvin, linux-kernel

Hi Reinette,

> On 9/24/2021 1:17 AM, Shaopeng Tan wrote:
> > When kzalloc fails, we should return ENOMEM instead of ENOSPC.
> >
> > Signed-off-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
> > ---
> > Hello,
> >
> > I just noticed this when I read the code.
> >
> > Thanks,
> >
> >   arch/x86/kernel/cpu/resctrl/rdtgroup.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> > b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> > index b57b3db9a6a7..a92d047476f6 100644
> > --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> > +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> > @@ -2854,7 +2854,7 @@ static int mkdir_rdt_prepare(struct kernfs_node
> *parent_kn,
> >   	/* allocate the rdtgroup. */
> >   	rdtgrp = kzalloc(sizeof(*rdtgrp), GFP_KERNEL);
> >   	if (!rdtgrp) {
> > -		ret = -ENOSPC;
> > +		ret = -ENOMEM;
> >   		rdt_last_cmd_puts("Kernel out of memory\n");
> >   		goto out_unlock;
> >   	}
> >
> 
> I do not know the original motivation for using ENOSPC but from what I can tell
> this error is propagated all the way to user space. This change thus has the
> consequence that any interface built on top of resctrl could be impacted.
> 
> Is there a specific issue that you are aiming to fix here?

I didn't detect any problem on machine, I noticed it by reading at the code. 

Elsewhere in resctrl code, if kzalloc fails, it returns ENOMEM.  
For example, in the same file(rdtgroup.c), 
2107         s = kzalloc(sizeof(*s), GFP_KERNEL); 
2108         if (!s) 
2109                 return -ENOMEM; 
so, I thought it wasn't intentionally to return ENOSPC. 

As you said it maybe impact user space,  
so, please ignore this patch if you don't think it needs to be changed. 

Thanks, 
Tan Shaopeng

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

end of thread, other threads:[~2021-09-28  4:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-24  8:17 [PATCH] x86/resctrl: Fix return code in mkdir_rdt_prepare() Shaopeng Tan
2021-09-24 18:53 ` Reinette Chatre
2021-09-28  4:44   ` tan.shaopeng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®