linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
To: Kent Overstreet <kent.overstreet@gmail.com>
Cc: linux-fsdevel@vger.kernel.org, linux-aio@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: aio: questions with ioctx_alloc() and large num_possible_cpus()
Date: Wed, 5 Oct 2016 14:21:27 -0300	[thread overview]
Message-ID: <965fc993-97c2-48b9-82e3-6c3444d0ffe5@linux.vnet.ibm.com> (raw)
In-Reply-To: <20161005063435.mtw2keukyxwbwo2k@kmo-pixel>

Hi Kent,

Thanks for commenting. I understood more of the code in trying to make
sense of your point, but there are some things still unclear about it;
if you could help a bit more, please.

Can you describe how a single thread might not be able to use all the
slots because 'up to about half of the reqs_available slots might
be on other percpu reqs_available' ?

I see that the thread might be scheduled on different CPUs (say, only
2 possible CPUs) and perform get_reqs_available() on both -- but that
only gives one req_batch to each CPU, and for req_batch to be half of
reqs_available its denominator needs to be 2, which doesn't happen w/
num_possible_cpus() * 4  -- which is 8.  So I'm a bit confused here.

     atomic_set(&ctx->reqs_available, ctx->nr_events - 1);
     ctx->req_batch = (ctx->nr_events - 1) / (num_possible_cpus() * 4);

On 10/05/2016 03:34 AM, Kent Overstreet wrote:
>> - why "num_possible_cpus() * 4", and why "max(nr_events, <it>)" ?

> For the scheme to work - percpu allocation of slots - we have to ensure that
> there aren't too many unused slots stranded on other CPUs. The stranding is
> limited to 1/4th of the slots [snip]

By 'unused slots' you mean the slots included in the batch allocated
to a particular cpu but not actually used by a thread in that cpu?
(e.g., get_reqs_available() called once, unused_slots == req_batch - 1)

Can you please detail a bit more how the limit to 1/4th of the slots is
ensured because of "num_possible_cpus() * 4", and what is the scenario
where the math is based on?  I've been thinking and assuming values for
a while now, and didn't figure out the point where / how it occurs.

Thanks for your support,

-- 
Mauricio Faria de Oliveira
IBM Linux Technology Center


  reply	other threads:[~2016-10-05 17:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-04 22:55 aio: questions with ioctx_alloc() and large num_possible_cpus() Mauricio Faria de Oliveira
2016-10-05  6:34 ` Kent Overstreet
2016-10-05 17:21   ` Mauricio Faria de Oliveira [this message]
2016-10-05 17:41 ` Benjamin LaHaise
2016-10-05 17:58   ` Mauricio Faria de Oliveira
2016-10-05 18:17     ` Benjamin LaHaise
2016-10-05 19:22       ` Mauricio Faria de Oliveira
2016-10-28 18:59       ` Jeff Moyer

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=965fc993-97c2-48b9-82e3-6c3444d0ffe5@linux.vnet.ibm.com \
    --to=mauricfo@linux.vnet.ibm.com \
    --cc=kent.overstreet@gmail.com \
    --cc=linux-aio@kvack.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --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).