From: Andrew Murray <amurray@mpcdata.com>
To: linux-sh@vger.kernel.org
Subject: RE: [PATCH] sh: Remove memset from coherent memory allocator (for
Date: Thu, 29 Jul 2010 14:03:20 +0000 [thread overview]
Message-ID: <9864723e22237deb7ba6cd399e1612f4@mail.gmail.com> (raw)
In-Reply-To: <AANLkTi=0=kR49SHE8mistKJ0hPpjwUk=xXSMw=K_i9Ne@mail.gmail.com>
> -----Original Message-----
> From: Matt Fleming [mailto:matt@console-pimps.org]
> Your mail client has word wrapped this patch. Check out
> Documentation/email-clients.txt to see if there are any tips for your
> client.
>
> This patch seems OK in principal but I think there's a safer way to get
> the results you want. With your patch, you've changed the semantics of
> dma_generic_alloc_coherent(). Previously it was guaranteed to return a
> chunk of zero'd memory, now you're relying on the caller passing
> __GFP_ZERO to indicate whether they want zero'd memory or not. Which
> means that if there's a bit of code that expects zero'd memory but
> doesn't pass __GFP_ZERO, it'll now be broken.
>
> (You could argue that this hypothetical caller of dma_alloc_coherent()
> is already broken if it doesn't pass __GFP_ZERO but my point is that it
> could be a lot of work to track down all the callers and figure out
> exactly what guarantees they expect).
>
> The safest approach is to follow what x86 does in its
> dma_generic_alloc_coherent() implementation; it adds the __GFP_ZERO
> flag
> unconditionally before allocating pages.
I share your concern (and also make the broken caller argument). New
patch...
From: Andrew Murray <amurray@mpc-data.co.uk>
This patch reduces the time taken to allocate coherent dma memory.
Signed-off-by: Andrew Murray <amurray@mpc-data.co.uk>
---
--- linux-2.6-old/arch/sh/mm/consistent.c 2010-07-25
05:01:33.813493496 +0100
+++ linux-2.6/arch/sh/mm/consistent.c 2010-07-25 08:11:28.969943650
+0100
@@ -38,11 +38,11 @@ void *dma_generic_alloc_coherent(struct
void *ret, *ret_nocache;
int order = get_order(size);
+ gfp |= __GFP_ZERO;
ret = (void *)__get_free_pages(gfp, order);
if (!ret)
return NULL;
- memset(ret, 0, size);
/*
* Pages from the page allocator may have data present in
* cache. So flush the cache before using uncached memory.
--
next prev parent reply other threads:[~2010-07-29 14:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-29 11:50 [PATCH] sh: Remove memset from coherent memory allocator (for Andrew Murray
2010-07-29 13:13 ` [PATCH] sh: Remove memset from coherent memory allocator (for comments) Matt Fleming
2010-07-29 14:03 ` Andrew Murray [this message]
2010-07-29 19:36 ` [PATCH] sh: Remove memset from coherent memory allocator (for Guennadi Liakhovetski
2010-07-29 19:52 ` [PATCH] sh: Remove memset from coherent memory allocator (for comments) Matt Fleming
2010-08-04 7:37 ` Paul Mundt
2010-08-04 7:53 ` [PATCH] sh: Remove memset from coherent memory allocator (for Andrew Murray
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=9864723e22237deb7ba6cd399e1612f4@mail.gmail.com \
--to=amurray@mpcdata.com \
--cc=linux-sh@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).