mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Query on lock protection in random number driver
@ 2008-01-11 11:08 Nikanth Karthikesan
  2008-01-11 11:12 ` Andi Kleen
       [not found] ` <47879DA2.BANGALORE.BLR.100.174746A.1.EEA6.1@1:7.BANGALORE.BLR.100.0.1.0.1@16>
  0 siblings, 2 replies; 4+ messages in thread
From: Nikanth Karthikesan @ 2008-01-11 11:08 UTC (permalink / raw)
  To: linux-kernel, mpm

A query on locks used to protect entropy_store

struct entropy_store {
	/* mostly-read data: */
	struct poolinfo *poolinfo;
	__u32 *pool;
	const char *name;
	int limit;
	struct entropy_store *pull;

	/* read-write data: */
	spinlock_t lock ____cacheline_aligned_in_smp;
	unsigned add_ptr;
	int entropy_count;
	int input_rotate;
};

Is this lock meant to protect all the data within the structure?
The lock is being taken whenever entropy_count is modified, but it is
not so when it is read, see random_poll(), random_read(). Either it
should be lock protected or made as atomic_t, right?

Also the globals random_read_wakeup_thresh and
random_write_wakeup_thresh are not at all protected by any locks! Why
locks are not needed for these?

Sorry, if that was a stupid question.

Thanks
Nikanth Karthikesan



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-01-11 12:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-11 11:08 Query on lock protection in random number driver Nikanth Karthikesan
2008-01-11 11:12 ` Andi Kleen
     [not found] ` <47879DA2.BANGALORE.BLR.100.174746A.1.EEA6.1@1:7.BANGALORE.BLR.100.0.1.0.1@16>
2008-01-11 11:28   ` Nikanth Karthikesan
2008-01-11 12:49     ` Andi Kleen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome