linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Doug Ledford <dledford@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Sasha Levin <levinsasha928@gmail.com>,
	kosaki.motohiro@jp.fujitsu.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ipc/mqueue: use correct gfp flags in msg_insert
Date: Wed, 16 May 2012 00:37:02 -0400	[thread overview]
Message-ID: <4FB32EEE.4090404@redhat.com> (raw)
In-Reply-To: <20120515143859.c3cad9b7.akpm@linux-foundation.org>

[-- Attachment #1: Type: text/plain, Size: 2798 bytes --]

On 5/15/2012 5:38 PM, Andrew Morton wrote:
> On Mon, 14 May 2012 22:45:57 -0400
> Doug Ledford <dledford@redhat.com> wrote:

>>> Switching to GFP_ATOMIC is a bit regrettable.  Can we avoid this by
>>> speculatively allocating the memory before taking the lock, then free
>>> it again if we ended up not using it?
>>
>> Not really, we take the lock in a different function than this and would
>> have to pass around a node struct and then free it if we didn't use it.
>>  I mean, it could be done, but it would fugly the calls around this up.
>>  The msg_insert() routine is called in two places.  In one place, the
>> lock is taken right there so you could allocate before and then call.
>> In the other, it is another function called with the lock held so now
>> you would have to pass the possible mem allocation around two functions.
>>  Doable, but ugly.
> 
> Well, it's not *too* bad: just pass a void** around, zero it if it got
> used, then unconditionally free it.  Nice and easy.
> 
> But in a contest between source-level beauty and runtime robustness,
> robustness surely wins?

Sure, things must be robustness.  It's just a question of what qualifies
as robust.

>>  On the other hand, this is a small struct that
>> should be coming off one of the small size kmem cache pools (4 pointers
>> total, a long, and an int, so kmalloc-32 or kmalloc-64 depending on
>> arch).  That doesn't seem like a likely candidate to fail if there is
>> memory pressure, especially considering that immediately prior to taking
>> the lock we call kmalloc with GFP_KERNEL (as part of load_msg()) and so
>> we should either not be under serious memory pressure or we would have
>> slept waiting for it to ease up.
> 
> True.  But weaselly!

And we don't rely on weaselly things in the kernel all the time? ;-)

>> I think I can imagine a better way to do this though as part of the
>> whole request to cache at least one rbnode entry so we get the 0 message
>> performance of the queue back.  I'll send that patch through once I've
>> verified it does what I think it will.
> 
> That sounds good.

I coded something up, but I'm not happy with it.  Trying again.  One of
my problems is I *really* don't like speculatively allocating this
little struct because in the common case this is a total waste of CPU
cycles.  While my patch sped up operations under any sort of decent
queue depth, it slowed down the queue empty case by 100ns.  I'm trying
to get some of that loss back, and doing a useless speculative
allocation doesn't help :-/

-- 
Doug Ledford <dledford@redhat.com>
              GPG KeyID: 0E572FDD
	      http://people.redhat.com/dledford

Infiniband specific RPMs available at
	      http://people.redhat.com/dledford/Infiniband


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 898 bytes --]

      reply	other threads:[~2012-05-16  4:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-14 21:05 [PATCH] ipc/mqueue: use correct gfp flags in msg_insert Sasha Levin
2012-05-14 23:54 ` Andrew Morton
2012-05-15  2:45   ` Doug Ledford
2012-05-15 21:38     ` Andrew Morton
2012-05-16  4:37       ` Doug Ledford [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=4FB32EEE.4090404@redhat.com \
    --to=dledford@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=levinsasha928@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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).