Request for mentee selection tasks (Checkpatch Documentation)

Lukas Bulwahn lukas.bulwahn at gmail.com
Mon Aug 2 12:23:15 UTC 2021


Dear Sri,

> > Then, the first task is to run checkpatch.pl on a few files below
> > and share the results:
> >
> > drivers/usb/gadget/legacy/raw_gadget.c
>
> Result:
>
> ./drivers/usb/gadget/legacy/raw_gadget.c:52: WARNING: consider using a
> completion

(snip)

>
> WARNING: consider using a completion
> (Not Documented)
> This warning suggests to use completion instead of semaphore.
>
> checkpatch.pl checks for iniialized semaphores, by checking
> for sema_init, if semaphores is initialized warns to use completion
> instead of semaphore.
>
> if ($line =~ /^.\s*sema_init.+,\W?0\W?\)/) {
>        WARN("CONSIDER_COMPLETION",
>             "consider using a completion\n" . $herecurr);
> }
>
> fix: completion has to be used instead of semaphore.
>

Can you do some further investigation and research what this warning is about?

E.g., Look at the commit and its commit message that introduced this
rule in checkpatch. Look in the kernel documentation for relevant
information on semaphores and completions, the difference and the
reasons to use one or the other synchonisation mechanism.

Summarize this information and provide some documentation on this
warning with various pointers for further reading and share that with
us.

We found 16 cases in the kernel tree:

drivers/crypto/ux500/cryp/cryp_core.c:1593:
WARNING:CONSIDER_COMPLETION: consider using a completion
drivers/crypto/ux500/hash/hash_core.c:1946:
WARNING:CONSIDER_COMPLETION: consider using a completion
drivers/gpu/drm/udl/udl_main.c:213: WARNING:CONSIDER_COMPLETION:
consider using a completion
drivers/infiniband/ulp/isert/ib_isert.c:2275:
WARNING:CONSIDER_COMPLETION: consider using a completion
drivers/input/misc/hp_sdc_rtc.c:88: WARNING:CONSIDER_COMPLETION:
consider using a completion
drivers/input/serio/hil_mlc.c:934: WARNING:CONSIDER_COMPLETION:
consider using a completion
drivers/input/serio/hp_sdc.c:904: WARNING:CONSIDER_COMPLETION:
consider using a completion
drivers/input/serio/hp_sdc.c:1033: WARNING:CONSIDER_COMPLETION:
consider using a completion
drivers/md/dm-region-hash.c:217: WARNING:CONSIDER_COMPLETION: consider
using a completion
drivers/parport/share.c:465: WARNING:CONSIDER_COMPLETION: consider
using a completion
drivers/usb/gadget/legacy/raw_gadget.c:52:
WARNING:CONSIDER_COMPLETION: consider using a completion
drivers/video/fbdev/udlfb.c:1888: WARNING:CONSIDER_COMPLETION:
consider using a completion
fs/xfs/xfs_buf.c:237: WARNING:CONSIDER_COMPLETION: consider using a completion
include/drm/task_barrier.h:59: WARNING:CONSIDER_COMPLETION: consider
using a completion
include/drm/task_barrier.h:60: WARNING:CONSIDER_COMPLETION: consider
using a completion
kernel/seccomp.c:1769: WARNING:CONSIDER_COMPLETION: consider using a completion

Can you please check which of these cases should be refactored (so the
checkpatch warning points to a valid suggestion to refactor the code)
or if checkpatch is wrong with its suggestion and why?

Thanks,

Lukas


More information about the Linux-kernel-mentees mailing list