public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: linux-kernel@vger.kernel.org, joerg.roedel@amd.com,
	akpm@linux-foundation.org
Subject: Re: [PATCH 1/2] dma-debug: add dma_debug_resize_entries() to adjust the number of dma_debug_entries
Date: Wed, 15 Apr 2009 12:27:43 +0200	[thread overview]
Message-ID: <20090415102743.GF6669@elte.hu> (raw)
In-Reply-To: <20090415182234R.fujita.tomonori@lab.ntt.co.jp>


* FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> wrote:

> On Tue, 14 Apr 2009 12:58:23 +0200
> Ingo Molnar <mingo@elte.hu> wrote:
> 
> > 
> > * FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> wrote:
> > 
> > > +int dma_debug_resize_entries(u32 num_entries)
> > > +{
> > > +	int i, delta, ret = 0;
> > > +	unsigned long flags;
> > > +	struct dma_debug_entry *entry;
> > > +
> > > +	spin_lock_irqsave(&free_entries_lock, flags);
> > > +
> > > +	if (nr_total_entries < num_entries) {
> > > +		delta = num_entries - nr_total_entries;
> > > +
> > > +		for (i = 0; i < delta; i++) {
> > > +			entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
> > > +			if (!entry)
> > > +				break;
> > 
> > hm, using GFP_ATOMIC within a spinlock is not a very nice thing to 
> > do in general. While this is boot-only and the GFP_ATOMIC will 
> > likely succeed, this could become non-boot functionality and then 
> > it's exposed to the momentary VM pressure situation that might make 
> > GFP_ATOMIC fail.
> > 
> > Please fix this to be GFP_KERNEL.
> 
> Ok, fixed though I'm not sure it matters. It's unlikely that this 
> could become non-boot functionality so I chose a simple way.
> 
> I've attached a fixed patch. It's unlikely that this function is 
> called concurrently so I don't try hard.

thanks, it looks nice and clean now.

GFP_ATOMIC (mis-)use is prominently detected by Andrew's 
barf-o-meter so even though it's probably fine here it's still 
better to just not get into the habit. People would then see it in 
an otherwise tidy looking piece of code and think it's an example to 
follow.

	Ingo

  reply	other threads:[~2009-04-15 10:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-14  0:43 [PATCH 1/2] dma-debug: add dma_debug_resize_entries() to adjust the number of dma_debug_entries FUJITA Tomonori
2009-04-14  0:43 ` [PATCH 2/2] gart: reimplement IOMMU_LEAK feature by using DMA_API_DEBUG FUJITA Tomonori
2009-04-14 10:48   ` Joerg Roedel
2009-04-15 11:24   ` [tip:core/iommu] x86 " tip-bot for FUJITA Tomonori
2009-04-14 10:47 ` [PATCH 1/2] dma-debug: add dma_debug_resize_entries() to adjust the number of dma_debug_entries Joerg Roedel
2009-04-14 10:58 ` Ingo Molnar
2009-04-15  9:22   ` FUJITA Tomonori
2009-04-15 10:27     ` Ingo Molnar [this message]
2009-04-15 11:24     ` [tip:core/iommu] " tip-bot for FUJITA Tomonori

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=20090415102743.GF6669@elte.hu \
    --to=mingo@elte.hu \
    --cc=akpm@linux-foundation.org \
    --cc=fujita.tomonori@lab.ntt.co.jp \
    --cc=joerg.roedel@amd.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