Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755264Ab3IYMGx (ORCPT ); Wed, 25 Sep 2013 08:06:53 -0400 Received: from mail-pd0-f172.google.com ([209.85.192.172]:59846 "EHLO mail-pd0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750989Ab3IYMGw (ORCPT ); Wed, 25 Sep 2013 08:06:52 -0400 Message-ID: <1380110810.3165.140.camel@edumazet-glaptop> Subject: Re: [PATCH RFC] random: introduce get_random_bytes_busy_wait_initialized From: Eric Dumazet To: Hannes Frederic Sowa Cc: Tom Herbert , davem@davemloft.net, netdev@vger.kernel.org, jesse.brandeburg@intel.com, tytso@mit.edu, linux-kernel@vger.kernel.org Date: Wed, 25 Sep 2013 05:06:50 -0700 In-Reply-To: <20130925090034.GC4904@order.stressinduktion.org> References: <1379980991.3165.37.camel@edumazet-glaptop> <20130924023038.GA22393@order.stressinduktion.org> <20130924033505.GB22393@order.stressinduktion.org> <1380001118.3165.41.camel@edumazet-glaptop> <20130924054532.GA24446@order.stressinduktion.org> <1380028797.3165.65.camel@edumazet-glaptop> <20130925090034.GC4904@order.stressinduktion.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit Mime-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 967 Lines: 30 On Wed, 2013-09-25 at 11:00 +0200, Hannes Frederic Sowa wrote: > /* > + * Busy loop until the nonblocking_pool is intialized and return > + * random data in buf of size nbytes. > + * > + * This is used by the network stack to defer the extraction of > + * entropy from the nonblocking_pool until the pool is initialized. > + * > + * We need to busy loop here, because we could be called from an > + * atomic section. > + */ > +void get_random_bytes_busy_wait_initialized(void *buf, int nbytes) > +{ > + while (!nonblocking_pool.initialized) > + cpu_relax(); > + get_random_bytes(buf, nbytes); > +} No idea if this can work if called from IRQ context. How is nonblocking_poll initialized if host has a single cpu ? -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/