All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@linux.intel.com>
To: Andi Kleen <andi@firstfloor.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [REVIEW] NVM Express driver
Date: Sat, 12 Mar 2011 00:51:46 -0500	[thread overview]
Message-ID: <20110312055146.GA4183@linux.intel.com> (raw)
In-Reply-To: <m24o79cmv4.fsf@firstfloor.org>

On Fri, Mar 11, 2011 at 02:29:19PM -0800, Andi Kleen wrote:
> Matthew Wilcox <willy@linux.intel.com> writes:
> > +
> > +static struct nvme_queue *get_nvmeq(struct nvme_ns *ns)
> > +{
> > +	int qid, cpu = get_cpu();
> > +	if (cpu < ns->dev->queue_count)
> > +		qid = cpu + 1;
> > +	else
> > +		qid = (cpu % rounddown_pow_of_two(ns->dev->queue_count))
> > + 1;
> 
> This will be likely a full divide, better use a mask.

I have a TODO to replace this calculation with a lookup; I've discovered
that not even all Intel systems number the CPUs in the logical fashion
(eg on a two-socket system; cpu 0 in socket 0, cpu 1 in socket 1, cpu
2 in socket 0, etc; some two socket systems have cpus 0-3 in socket 0;
4-7 in socket 1; and 8-15 are the HT siblings of 0-7).

Is there a good API to iterate through each socket, then each core in a
socket, then each HT sibling?  eg, if I have 20 queues and 2x6x2 CPUs,
I want to assign at least one queue to each core; some threads will get
their own queues and others will have to share with their HT sibling.

> > +	nprps = DIV_ROUND_UP(length, PAGE_SIZE);
> > +	npages = DIV_ROUND_UP(8 * nprps, PAGE_SIZE);
> > +	prps = kmalloc(sizeof(*prps) + sizeof(__le64 *) * npages, GFP_ATOMIC);
> > +	prp_page = 0;
> > +	if (nprps <= (256 / 8)) {
> > +		pool = dev->prp_small_pool;
> > +		prps->npages = 0;
> 
> 
> Unchecked GFP_ATOMIC allocation? That will oops soon.
> Besides GFP_ATOMIC a very risky thing to do on a low memory situation,
> which can trigger writeouts.

Ah yes, thank you.  There are a few other places like this.  Bizarrely,
they've not oopsed during the xfstests runs.

My plan for this is, instead of using a mempool, to submit partial I/Os
in the rare cases where a write cannot allocate memory.  I have the
design in my head, just not committed to code yet.  The design also
avoids allocating any memory in the driver for I/Os that do not cross
a page boundary.


  reply	other threads:[~2011-03-12  5:51 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-03 20:47 [REVIEW] NVM Express driver Matthew Wilcox
2011-03-03 21:13 ` Greg KH
2011-03-03 21:41   ` Matthew Wilcox
2011-03-03 21:51     ` Greg KH
2011-03-03 22:07       ` Matthew Wilcox
2011-03-03 22:22         ` Greg KH
2011-03-04  2:25           ` Andy Lutomirski
2011-03-04  9:02             ` el es
2011-03-04 21:29             ` Greg KH
2011-03-04 12:43           ` Alan Cox
2011-03-04 21:28             ` Greg KH
2011-03-04 21:59               ` Alan Cox
2011-03-04 22:10                 ` Greg KH
2011-03-04 22:33                   ` Alan Cox
2011-03-04 23:10                     ` Greg KH
2011-03-05 10:28                       ` Alan Cox
2011-03-04 12:52     ` Mark Brown
2011-03-03 21:33 ` Randy Dunlap
2011-03-04 13:06 ` Christoph Hellwig
2011-03-04 14:46   ` Matthew Wilcox
2011-03-11 22:29 ` Andi Kleen
2011-03-12  5:51   ` Matthew Wilcox [this message]
2011-03-13 17:14     ` Andi Kleen
2011-03-13 17:14       ` Andi Kleen
2011-03-13 18:24 ` Arnd Bergmann

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=20110312055146.GA4183@linux.intel.com \
    --to=willy@linux.intel.com \
    --cc=andi@firstfloor.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 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.