From: Khadija Kamran <kamrankhadijadj@gmail.com>
To: Ira Weiny <ira.weiny@intel.com>
Cc: outreachy@lists.linux.dev
Subject: Re: Code cleanups are not always simple.
Date: Tue, 21 Mar 2023 21:36:29 +0500 [thread overview]
Message-ID: <ZBndDYO5pFSOI1m2@khadija-virtual-machine> (raw)
In-Reply-To: <6418f59a8b3c1_2c274e2942e@iweiny-mobl.notmuch>
On Mon, Mar 20, 2023 at 05:08:58PM -0700, Ira Weiny wrote:
> Cleaning up code is not always easy. Yes there are various rules, coding
> styles and tools which can automate the process. But we should all remember to
> think about the problem being reported and determine if a simple search/replace
> is the proper thing to do. I think this is becoming more apparent as the
> number of things checkpatch reports on is dwindling to these more complicated
> issues.
>
> So I'd like to call attention to a couple of problems which have required a bit
> more attention. Hopefully by highlighting these problems folks will be more
> aware when looking at future issues.
>
> The first problem was a week or so back when Khadija was trying to fix line
> length formatting.[1] The repeated attempts were causing circular problems
> with checkpatch failing on different checks. The core issue was that
> checkpatch was only checking the symptoms of the issue, not the issue itself.
> Checkpatch and the kernel coding style are in place not to enforce random rules
> on how folks write code. They are there to make the code cleaner, less buggy,
> and easier to maintain.
>
> Today I saw a similar situation. Julia called out the need to make macro
> definitions safer by turning them into inline functions.[2]
>
> But Sumitra took that a bit too literally.[3] The container_of() macro is
> useful on it's own. The only reason to create additional helper functions is
> when the conversion is either more complicated or used so much that the bulk of
> the code becomes much much cleaner.
>
> I'll end this with a recent example which is part of the kmap() project.
>
> I was looking at the call to kmap_atomic() in memcpy_page_flushcache() inside
> the x86 code. At first it looks like a simple substitute and replace from
> kmap_atmoic() to kmap_local_page(). But I took the time to understand the
> context of where memcpy_page_flushcache() was called. Doing so made me realize
> it was not called at all!!! The proper fix was to simply remove the call
> entirely from the kernel.
>
> I know you are all excited to get your first patches into the kernel. But even
> simple patches take time. After removing these calls I needed to ensure that
> x86, powerpc, and arm all compiled without issues. I used both 'git grep' and
> cscope to ensure I removed the header file declarations. Even then there was
> discussion because I accidentally submitted as a series which made a bit more
> work for the maintainers.[5]
>
> So in summary take your time. Try to understand why checkpatch or other tools
> are flagging errors.
>
> Most importantly, don't be afraid to take your time when submitting patches.
>
> Ira
>
> [1] https://lore.kernel.org/all/640e75cfd8fc_229a89294a3@iweiny-mobl.notmuch/
> [2] https://lore.kernel.org/all/124d2ef9-6f1d-2652-c88d-161f1bc06443@inria.fr/
> [3] https://lore.kernel.org/all/ZBh%2Fs5lyONaF37gs@kroah.com/
> [4] https://lore.kernel.org/all/20221230-kmap-x86-v1-0-15f1ecccab50@intel.com/
> [5] https://lore.kernel.org/all/3523ddf9-03f5-3179-9f39-cec09f79aa97@intel.com/
>
Hey Ira,
Thank you for the mail. I will make sure to keep your instructions in
mind while working on the upcoming patches.
Thank you,
Regards,
Khadija
Thank you
prev parent reply other threads:[~2023-03-21 16:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-21 0:08 Code cleanups are not always simple Ira Weiny
2023-03-21 1:15 ` Alison Schofield
2023-03-21 6:47 ` Julia Lawall
2023-03-21 9:01 ` Sumitra Sharma
2023-03-21 16:36 ` Khadija Kamran [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZBndDYO5pFSOI1m2@khadija-virtual-machine \
--to=kamrankhadijadj@gmail.com \
--cc=ira.weiny@intel.com \
--cc=outreachy@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.