From: Tejun Heo <tj@kernel.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Linux Kernel <linux-kernel@vger.kernel.org>,
Yinghai Lu <yhlu.kernel@gmail.com>
Subject: Re: [GIT PULL] percpu fixes for 2.6.32-rc6
Date: Thu, 12 Nov 2009 20:29:52 +0900 [thread overview]
Message-ID: <4AFBF1B0.8010906@kernel.org> (raw)
In-Reply-To: <20091112110741.GC24684@elte.hu>
Hello, Ingo.
11/12/2009 08:07 PM, Ingo Molnar wrote:
> Well, the pcpu_alloc() function is 115 lines which is a bit long. It
> does 2-3 things while a function should try to do one thing.
I agree for low level / utility functions but for top level functions
which direct the flow of the whole logic, I usually prefer to put them
flat. To me, that way things seem less obfuscated.
> Putting the reserved allocation into a separate function also makes the
> 'main' path of logic more visible and obstructed less by rare details.
>
> The indentation i pinpointed is 4 levels deep:
>
> err = "failed to extend area map of "
> "reserved chunk";
>
> which is a bit too much IMO - the code starts in the middle of the
> screen, there's barely any space to do anything meaningful.
Well, all that's there is error exit. Surrounding code segment is,
if (pcpu_extend_area_map(chunk, new_alloc) < 0) {
err = "failed to extend area map of "
"reserved chunk";
goto fail_unlock_mutex;
}
So, we might as well just do
err = "failed to extend area map of reserved chunk";
if (pcpu_extend_area_map(chunk, new_alloc) < 0)
goto fail_unlock_mutex;
> But there's other line wrap artifacts as well further down:
>
> if (pcpu_extend_area_map(chunk,
> new_alloc) < 0) {
This one is uglier and one level deeper than the previous one. The
resulting nesting was one of the reasons why I factored out
pcpu_extend_area_map() as a whole and switched on the return value but
that obfuscated locking. Although it nests quite a bit, I don't think
the loop there is too bad. It shows what it does pretty well.
> But ... there's no hard rules here and i've seen functions where 4
> levels of indentation were just ok. Anyway, i just gave you my opinion,
> and i'm definitely more on the nitpicky side of the code quality
> equilibrium, YMMV.
Indentation and code style are actually something I end up spending
quite some time on and I did think about the second one. Factoring
out without hiding locking is a bit difficult but if I rename
new_alloc to new_len, I can fit that thing onto a single line but that
would probably require renaming matching local variable in
pcpu_extend_area_map() which will end up generating unnecessary amount
of diff obfuscating the real change. At that point, I just thought we
could live with one slightly ugly line break.
So, I don't know. Pros and cons on these things depend too much on
personal tastes (and even mood at the time of writing) to form uniform
standard to follow.
Thanks.
--
tejun
next prev parent reply other threads:[~2009-11-12 11:28 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-10 6:04 [GIT PULL] percpu fixes for 2.6.32-rc6 Tejun Heo
2009-11-10 17:10 ` Linus Torvalds
2009-11-10 18:33 ` Tejun Heo
2009-11-10 18:54 ` Linus Torvalds
2009-11-10 19:25 ` Tejun Heo
2009-11-10 19:37 ` Ingo Molnar
2009-11-10 19:50 ` Tejun Heo
2009-11-10 21:42 ` Linus Torvalds
2009-11-11 3:55 ` Tejun Heo
2009-11-11 11:31 ` Ingo Molnar
2009-11-11 12:21 ` Tejun Heo
2009-11-11 19:57 ` Ingo Molnar
2009-11-12 10:11 ` Tejun Heo
2009-11-12 10:36 ` Ingo Molnar
2009-11-12 10:58 ` Tejun Heo
2009-11-12 11:25 ` Ingo Molnar
2009-11-12 14:26 ` Oliver Neukum
2009-11-12 15:17 ` Linus Torvalds
2009-11-12 15:30 ` Tejun Heo
2009-11-12 15:45 ` Tejun Heo
2009-11-12 15:52 ` Linus Torvalds
2009-11-12 17:04 ` Andres Baldrich
2009-11-12 17:18 ` Linus Torvalds
2009-11-12 18:04 ` Ingo Molnar
2009-11-12 18:14 ` Andi Kleen
2009-11-12 11:07 ` Ingo Molnar
2009-11-12 11:29 ` Tejun Heo [this message]
2009-11-11 8:49 ` [PATCH percpu#for-linus] percpu: restructure pcpu_extend_area_map() to fix bugs and improve readability Tejun Heo
2009-11-11 19:25 ` Linus Torvalds
2009-11-10 19:44 ` [GIT PULL] percpu fixes for 2.6.32-rc6 Tejun Heo
-- strict thread matches above, loose matches on Subject: below --
2009-11-13 3:53 Tejun Heo
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=4AFBF1B0.8010906@kernel.org \
--to=tj@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=torvalds@linux-foundation.org \
--cc=yhlu.kernel@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox