lkml.org 
[lkml]   [2009]   [Nov]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [PATCH 1/2] hw_random: core updates to allow more efficient drivers
From
Date
On Thu, 2009-11-26 at 00:25 +0000, Ian Molton wrote:
> This patch implements a new method by which hw_random hardware drivers
> can pass data to the core more efficiently, using a shared buffer.
>
> The old methods have been retained as a compatability layer until all the
> drivers have been updated.
>
> Signed-off-by: Ian Molton <ian.molton@collabora.co.uk>
> ---
> drivers/char/hw_random/core.c | 120 ++++++++++++++++++++++++++---------------
> include/linux/hw_random.h | 9 ++-
> 2 files changed, 82 insertions(+), 47 deletions(-)
>
> diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
> index 1573aeb..e179afd 100644
> --- a/drivers/char/hw_random/core.c
> +++ b/drivers/char/hw_random/core.c
> @@ -47,12 +47,14 @@
> #define RNG_MODULE_NAME "hw_random"
> #define PFX RNG_MODULE_NAME ": "
> #define RNG_MISCDEV_MINOR 183 /* official */
> +#define RNG_BUFFSIZE 64
>
>
> static struct hwrng *current_rng;
> static LIST_HEAD(rng_list);
> static DEFINE_MUTEX(rng_mutex);
> -
> +static u8 *rng_buffer;

How about just:

static u8 rng_buffer[RNG_BUFFSIZE] __cacheline_aligned;

And lose all the kmalloc and kfree code? The memory use will be smaller,
even when the buffer isn't needed.

> + if (!data_avail) {
> + bytes_read = rng_get_data(current_rng, rng_buffer,
> + RNG_BUFFSIZE, !(filp->f_flags & O_NONBLOCK));

No need to pass rng_buffer to the helper as there's only one with global
scope.

--
http://selenic.com : development and support for Mercurial and Linux




\
 
 \ /
  Last update: 2009-11-26 02:07    [W:0.079 / U:0.348 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site