Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755486Ab3IYNfd (ORCPT ); Wed, 25 Sep 2013 09:35:33 -0400 Received: from order.stressinduktion.org ([87.106.68.36]:50228 "EHLO order.stressinduktion.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754612Ab3IYNfb (ORCPT ); Wed, 25 Sep 2013 09:35:31 -0400 Date: Wed, 25 Sep 2013 15:35:30 +0200 From: Hannes Frederic Sowa To: Eric Dumazet Cc: Tom Herbert , davem@davemloft.net, netdev@vger.kernel.org, jesse.brandeburg@intel.com, tytso@mit.edu, linux-kernel@vger.kernel.org Subject: Re: [PATCH RFC] random: introduce get_random_bytes_busy_wait_initialized Message-ID: <20130925133530.GD4904@order.stressinduktion.org> Mail-Followup-To: Eric Dumazet , Tom Herbert , davem@davemloft.net, netdev@vger.kernel.org, jesse.brandeburg@intel.com, tytso@mit.edu, linux-kernel@vger.kernel.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> <1380110810.3165.140.camel@edumazet-glaptop> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1380110810.3165.140.camel@edumazet-glaptop> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1266 Lines: 35 On Wed, Sep 25, 2013 at 05:06:50AM -0700, Eric Dumazet wrote: > 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 ? We increase the entropy_count and can initialize the random pool from handle_irq_event. We can document that it should not get called from irq context and maybe add a WARN_ON(irqs_disabled())? -- 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/