linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Wei Yang <weiyang@linux.vnet.ibm.com>
Cc: cl@linux-foundation.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] percpu: stop the loop when a cpu belongs to a new group
Date: Mon, 28 Oct 2013 07:31:20 -0400	[thread overview]
Message-ID: <20131028113120.GB11541@mtj.dyndns.org> (raw)
In-Reply-To: <20131028030055.GC15642@weiyang.vnet.ibm.com>

Hello,

On Mon, Oct 28, 2013 at 11:00:55AM +0800, Wei Yang wrote:
> >Does this actually matter?  If so, it'd probably make a lot more sense
> >to start inner loop at @cpu + 1 so that it becomes O(N).
> 
> One of the worst case in my mind:
> 
> CPU:        0    1    2    3    4    ...
> Group:      0    1    2    3    4    ...
> (sounds it is impossible in the real world)

I was wondering whether you had an actual case where this actually
matters or it's just something you thought of while reading the code.

> Every time, when we encounter a new CPU and try to assign it to a group, we
> found it belongs to a new group. The original logic will iterate on all old
> CPUs again, while the new logic could skip this and assign it to a new group.
> 
> Again, this is a tiny change, which doesn't matters a lot.

I think it *could* matter because the current implementation is O(N^2)
where N is the number of CPUs.  On machines, say, with 4k CPU, it's
gonna loop 16M times but then again even that takes only a few
millisecs on modern machines.

> BTW, I don't get your point for "start inner loop at @cpu+1".
> 
> The original logic is:
> 	loop 1:   0 - nr_cpus
> 	loop 2:      0 - (cpu - 1)
> 
> If you found one better approach to improve the logic, I believe all the users
> will appreciate your efforts :-)

Ooh, right, I forgot about the break and then I thought somehow that
would make it O(N).  Sorry about that.  I blame jetlag. :)

Yeah, I don't know.  The function is quite hairy which makes me keep
things simpler and reluctant to make changes unless it actually makes
non-trivial difference.  The change looks okay to me but it seems
neither necessary or substantially beneficial and if my experience is
anything to go by, *any* change involves some risk of brekage no
matter how innocent it may look, so given the circumstances, I'd like
to keep things the way they are.

Thanks a lot!

-- 
tejun

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2013-10-28 11:31 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-21  8:58 [PATCH 1/3] percpu: stop the loop when a cpu belongs to a new group Wei Yang
2013-10-21  8:58 ` [PATCH 2/3] percpu: merge two loops when setting up group info Wei Yang
2013-10-27 12:35   ` Tejun Heo
2013-10-28  2:37     ` Wei Yang
2013-10-21  8:58 ` [PATCH 3/3] percpu: little optimization on calculating pcpu_unit_size Wei Yang
2013-10-27 12:36   ` Tejun Heo
2013-10-28  2:43     ` Wei Yang
2013-10-27 12:30 ` [PATCH 1/3] percpu: stop the loop when a cpu belongs to a new group Tejun Heo
2013-10-28  3:00   ` Wei Yang
2013-10-28 11:31     ` Tejun Heo [this message]
2013-10-28 15:17       ` Wei Yang
2013-11-20  3:00         ` Wei Yang
2013-11-20  5:51           ` Tejun Heo
2013-11-20  6:58             ` Wei Yang
2013-11-22 23:04             ` Tejun Heo
2013-11-24  1:48               ` Wei Yang

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=20131028113120.GB11541@mtj.dyndns.org \
    --to=tj@kernel.org \
    --cc=cl@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=weiyang@linux.vnet.ibm.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;
as well as URLs for NNTP newsgroup(s).