Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1296313 > unrolled thread

Re: [PATCH] staging: lustre/lustre/libcfs: Fix type mismatch reported by sparse

Started byGreg Kroah-Hartman <gregkh@linuxfoundation.org>
First post2015-12-22 00:50 +0100
Last post2015-12-23 07:30 +0100
Articles 5 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH] staging: lustre/lustre/libcfs: Fix type mismatch  reported by sparse Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-12-22 00:50 +0100
    Re: [PATCH] staging: lustre/lustre/libcfs: Fix type mismatch reported  by sparse Niranjan Dighe <niranjan.dighe@gmail.com> - 2015-12-22 14:10 +0100
      Re: [PATCH] staging: lustre/lustre/libcfs: Fix type mismatch  reported by sparse Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-12-22 16:30 +0100
      Re: [PATCH] staging: lustre/lustre/libcfs: Fix type mismatch  reported by sparse "Dilger, Andreas" <andreas.dilger@intel.com> - 2015-12-22 23:10 +0100
        Re: [PATCH] staging: lustre/lustre/libcfs: Fix type mismatch reported  by sparse Niranjan Dighe <niranjan.dighe@gmail.com> - 2015-12-23 07:30 +0100

#1296313 — Re: [PATCH] staging: lustre/lustre/libcfs: Fix type mismatch reported by sparse

FromGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Date2015-12-22 00:50 +0100
SubjectRe: [PATCH] staging: lustre/lustre/libcfs: Fix type mismatch reported by sparse
Message-ID<qIinh-4Eb-37@gated-at.bofh.it>
On Wed, Dec 09, 2015 at 10:38:13PM +0530, Niranjan Dighe wrote:
> The third argument to function kportal_memhog_alloc is expected to
> be gfp_t whereas the actual argument was unsigned int. Fix this by
> explicitly typecasting to gfp_t
> 
> Signed-off-by: Niranjan Dighe <niranjan.dighe@gmail.com>
> ---
>  drivers/staging/lustre/lustre/libcfs/module.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c
> index 96d9d46..9c79f6e 100644
> --- a/drivers/staging/lustre/lustre/libcfs/module.c
> +++ b/drivers/staging/lustre/lustre/libcfs/module.c
> @@ -268,7 +268,7 @@ static int libcfs_ioctl_int(struct cfs_psdev_file *pfile, unsigned long cmd,
>  			/* XXX The ioc_flags is not GFP flags now, need to be fixed */
>  			err = kportal_memhog_alloc(pfile->private_data,
>  						   data->ioc_count,
> -						   data->ioc_flags);
> +					(__force gfp_t)data->ioc_flags);

No, please fix the type to be correct properly, like the comment says
needs to be done.

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1296776 — Re: [PATCH] staging: lustre/lustre/libcfs: Fix type mismatch reported by sparse

FromNiranjan Dighe <niranjan.dighe@gmail.com>
Date2015-12-22 14:10 +0100
SubjectRe: [PATCH] staging: lustre/lustre/libcfs: Fix type mismatch reported by sparse
Message-ID<qIuRs-4nK-9@gated-at.bofh.it>
In reply to#1296313
On Tue, Dec 22, 2015 at 5:14 AM, Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
> On Wed, Dec 09, 2015 at 10:38:13PM +0530, Niranjan Dighe wrote:
>> The third argument to function kportal_memhog_alloc is expected to
>> be gfp_t whereas the actual argument was unsigned int. Fix this by
>> explicitly typecasting to gfp_t
>>
>> Signed-off-by: Niranjan Dighe <niranjan.dighe@gmail.com>
>> ---
>>  drivers/staging/lustre/lustre/libcfs/module.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c
>> index 96d9d46..9c79f6e 100644
>> --- a/drivers/staging/lustre/lustre/libcfs/module.c
>> +++ b/drivers/staging/lustre/lustre/libcfs/module.c
>> @@ -268,7 +268,7 @@ static int libcfs_ioctl_int(struct cfs_psdev_file *pfile, unsigned long cmd,
>>                       /* XXX The ioc_flags is not GFP flags now, need to be fixed */
>>                       err = kportal_memhog_alloc(pfile->private_data,
>>                                                  data->ioc_count,
>> -                                                data->ioc_flags);
>> +                                     (__force gfp_t)data->ioc_flags);
>
> No, please fix the type to be correct properly, like the comment says
> needs to be done.
>
> thanks,
>
> greg k-h

Hello Greg,

I could see that the ioc_flags member of the struct libcfs_ioctl_data
is used as gfp_t only in the
case of the ioctl IOC_LIBCFS_MEMHOG. I can think of following ways to
correct it -

1. Create a union that has 2 different types encapsulated, something like this -
        union {
                __u32 ioc_flags;
                gfp_t alloc_flags;
        }flags;
Because, the ioc_flags seems to be used in different contexts at
different places throughout the
drivers/staging/lustre directory.

2. Is it OK to hardcode the appropriate gfp_t flags for the
IOC_LIBCFS_MEMHOG, as the userspace
seems to be taking the decision about the page allocation
zone/strategy, is this what is intended?


Regards,
Niranjan Dighe
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1296837

FromGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Date2015-12-22 16:30 +0100
Message-ID<qIx2X-5EL-27@gated-at.bofh.it>
In reply to#1296776
On Tue, Dec 22, 2015 at 06:35:21PM +0530, Niranjan Dighe wrote:
> On Tue, Dec 22, 2015 at 5:14 AM, Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> > On Wed, Dec 09, 2015 at 10:38:13PM +0530, Niranjan Dighe wrote:
> >> The third argument to function kportal_memhog_alloc is expected to
> >> be gfp_t whereas the actual argument was unsigned int. Fix this by
> >> explicitly typecasting to gfp_t
> >>
> >> Signed-off-by: Niranjan Dighe <niranjan.dighe@gmail.com>
> >> ---
> >>  drivers/staging/lustre/lustre/libcfs/module.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c
> >> index 96d9d46..9c79f6e 100644
> >> --- a/drivers/staging/lustre/lustre/libcfs/module.c
> >> +++ b/drivers/staging/lustre/lustre/libcfs/module.c
> >> @@ -268,7 +268,7 @@ static int libcfs_ioctl_int(struct cfs_psdev_file *pfile, unsigned long cmd,
> >>                       /* XXX The ioc_flags is not GFP flags now, need to be fixed */
> >>                       err = kportal_memhog_alloc(pfile->private_data,
> >>                                                  data->ioc_count,
> >> -                                                data->ioc_flags);
> >> +                                     (__force gfp_t)data->ioc_flags);
> >
> > No, please fix the type to be correct properly, like the comment says
> > needs to be done.
> >
> > thanks,
> >
> > greg k-h
> 
> Hello Greg,
> 
> I could see that the ioc_flags member of the struct libcfs_ioctl_data
> is used as gfp_t only in the
> case of the ioctl IOC_LIBCFS_MEMHOG. I can think of following ways to
> correct it -
> 
> 1. Create a union that has 2 different types encapsulated, something like this -
>         union {
>                 __u32 ioc_flags;
>                 gfp_t alloc_flags;
>         }flags;
> Because, the ioc_flags seems to be used in different contexts at
> different places throughout the
> drivers/staging/lustre directory.

This crosses the user/kernel boundry?  Hah, no, just drop it, don't
touch this at all, lustre ioctls are a complete mess and need to be
fixed up by the authors who can test them, just leave this alone for
now, sorry.

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1297085

From"Dilger, Andreas" <andreas.dilger@intel.com>
Date2015-12-22 23:10 +0100
Message-ID<qIDi1-1cT-11@gated-at.bofh.it>
In reply to#1296776
On 2015/12/22, 06:05, "Niranjan Dighe" <niranjan.dighe@gmail.com> wrote:

>On Tue, Dec 22, 2015 at 5:14 AM, Greg Kroah-Hartman
><gregkh@linuxfoundation.org> wrote:
>> On Wed, Dec 09, 2015 at 10:38:13PM +0530, Niranjan Dighe wrote:
>>> The third argument to function kportal_memhog_alloc is expected to
>>> be gfp_t whereas the actual argument was unsigned int. Fix this by
>>> explicitly typecasting to gfp_t
>>>
>>> Signed-off-by: Niranjan Dighe <niranjan.dighe@gmail.com>
>>> ---
>>>  drivers/staging/lustre/lustre/libcfs/module.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/staging/lustre/lustre/libcfs/module.c
>>>b/drivers/staging/lustre/lustre/libcfs/module.c
>>> index 96d9d46..9c79f6e 100644
>>> --- a/drivers/staging/lustre/lustre/libcfs/module.c
>>> +++ b/drivers/staging/lustre/lustre/libcfs/module.c
>>> @@ -268,7 +268,7 @@ static int libcfs_ioctl_int(struct cfs_psdev_file
>>>*pfile, unsigned long cmd,
>>>                       /* XXX The ioc_flags is not GFP flags now, need
>>>to be fixed */
>>>                       err = kportal_memhog_alloc(pfile->private_data,
>>>                                                  data->ioc_count,
>>> -                                                data->ioc_flags);
>>> +                                     (__force gfp_t)data->ioc_flags);
>>
>> No, please fix the type to be correct properly, like the comment says
>> needs to be done.
>>
>> thanks,
>>
>> greg k-h
>
>Hello Greg,
>
>I could see that the ioc_flags member of the struct libcfs_ioctl_data
>is used as gfp_t only in the
>case of the ioctl IOC_LIBCFS_MEMHOG. I can think of following ways to
>correct it -
>
>1. Create a union that has 2 different types encapsulated, something like
>this -
>        union {
>                __u32 ioc_flags;
>                gfp_t alloc_flags;
>        }flags;
>Because, the ioc_flags seems to be used in different contexts at
>different places throughout the
>drivers/staging/lustre directory.
>
>2. Is it OK to hardcode the appropriate gfp_t flags for the
>IOC_LIBCFS_MEMHOG, as the userspace
>seems to be taking the decision about the page allocation
>zone/strategy, is this what is intended?

The memhog functionality is used to introduce memory pressure on a client
or server during operation to test error handling as well as memory
allocation deadlocks (e.g. GFP_KERNEL used where GFP_NOFS should be used).
There are other ways to do this in the kernel today, so all of the memhog
code could just be deleted I think.

This looks like kportal_memhog_alloc(), kportal_memhog_free(),
IOC_LIBCFS_MEMHOG, and struct libcfs_device_userstate could be removed.


Cheers, Andreas

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1297264 — Re: [PATCH] staging: lustre/lustre/libcfs: Fix type mismatch reported by sparse

FromNiranjan Dighe <niranjan.dighe@gmail.com>
Date2015-12-23 07:30 +0100
SubjectRe: [PATCH] staging: lustre/lustre/libcfs: Fix type mismatch reported by sparse
Message-ID<qIL5T-62O-5@gated-at.bofh.it>
In reply to#1297085
On Wed, Dec 23, 2015 at 3:34 AM, Dilger, Andreas
<andreas.dilger@intel.com> wrote:
> On 2015/12/22, 06:05, "Niranjan Dighe" <niranjan.dighe@gmail.com> wrote:
>
>>On Tue, Dec 22, 2015 at 5:14 AM, Greg Kroah-Hartman
>><gregkh@linuxfoundation.org> wrote:
>>> On Wed, Dec 09, 2015 at 10:38:13PM +0530, Niranjan Dighe wrote:
>>>> The third argument to function kportal_memhog_alloc is expected to
>>>> be gfp_t whereas the actual argument was unsigned int. Fix this by
>>>> explicitly typecasting to gfp_t
>>>>
>>>> Signed-off-by: Niranjan Dighe <niranjan.dighe@gmail.com>
>>>> ---
>>>>  drivers/staging/lustre/lustre/libcfs/module.c | 2 +-
>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/staging/lustre/lustre/libcfs/module.c
>>>>b/drivers/staging/lustre/lustre/libcfs/module.c
>>>> index 96d9d46..9c79f6e 100644
>>>> --- a/drivers/staging/lustre/lustre/libcfs/module.c
>>>> +++ b/drivers/staging/lustre/lustre/libcfs/module.c
>>>> @@ -268,7 +268,7 @@ static int libcfs_ioctl_int(struct cfs_psdev_file
>>>>*pfile, unsigned long cmd,
>>>>                       /* XXX The ioc_flags is not GFP flags now, need
>>>>to be fixed */
>>>>                       err = kportal_memhog_alloc(pfile->private_data,
>>>>                                                  data->ioc_count,
>>>> -                                                data->ioc_flags);
>>>> +                                     (__force gfp_t)data->ioc_flags);
>>>
>>> No, please fix the type to be correct properly, like the comment says
>>> needs to be done.
>>>
>>> thanks,
>>>
>>> greg k-h
>>
>>Hello Greg,
>>
>>I could see that the ioc_flags member of the struct libcfs_ioctl_data
>>is used as gfp_t only in the
>>case of the ioctl IOC_LIBCFS_MEMHOG. I can think of following ways to
>>correct it -
>>
>>1. Create a union that has 2 different types encapsulated, something like
>>this -
>>        union {
>>                __u32 ioc_flags;
>>                gfp_t alloc_flags;
>>        }flags;
>>Because, the ioc_flags seems to be used in different contexts at
>>different places throughout the
>>drivers/staging/lustre directory.
>>
>>2. Is it OK to hardcode the appropriate gfp_t flags for the
>>IOC_LIBCFS_MEMHOG, as the userspace
>>seems to be taking the decision about the page allocation
>>zone/strategy, is this what is intended?
>
> The memhog functionality is used to introduce memory pressure on a client
> or server during operation to test error handling as well as memory
> allocation deadlocks (e.g. GFP_KERNEL used where GFP_NOFS should be used).
> There are other ways to do this in the kernel today, so all of the memhog
> code could just be deleted I think.
>
> This looks like kportal_memhog_alloc(), kportal_memhog_free(),
> IOC_LIBCFS_MEMHOG, and struct libcfs_device_userstate could be removed.
>
>
> Cheers, Andreas
>

Thanks Andreas, I will send out a separate patch with the cleanup as
you suggested.

Regards,
Niranjan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web