# Re: \[PATCH v25 01/12\] Linux Random Number Generator

- From: Thomas Gleixner \<hidden\>
- Date: 2019-11-16 11:25:37 
- List: linux-api
- Page: https://ratatoskr.run/linux-api/2019/11/5778528
- Thread: https://ratatoskr.run/linux-crypto/2019/11/5773044/t.md

```text
On Sat, 16 Nov 2019, Stephan Müller wrote:
> +/**
> + * Hot code path - Callback for interrupt handler
> + */
> +void add_interrupt_randomness(int irq, int irq_flags)
> +{
> +	lrng_time_process();
> +
> +	if (!lrng_pool_highres_timer()) {
> +		struct pt_regs *regs = get_irq_regs();
> +		static atomic_t reg_idx = ATOMIC_INIT(0);
> +		u64 ip;
> +
> +		lrng_pool_lfsr_u32(jiffies);
> +		lrng_pool_lfsr_u32(irq);
> +		lrng_pool_lfsr_u32(irq_flags);
> +
> +		if (regs) {
> +			u32 *ptr = (u32 *)regs;
> +			int reg_ptr = atomic_add_return_relaxed(1, &reg_idx);
> +			size_t n = (sizeof(struct pt_regs) / sizeof(u32));
> +
> +			ip = instruction_pointer(regs);
> +			lrng_pool_lfsr_u32(*(ptr + (reg_ptr % n)));
> +		} else
> +			ip = _RET_IP_;
> +
> +		lrng_pool_lfsr_u32(ip >> 32);
> +		lrng_pool_lfsr_u32(ip);
> +	}

Is there a way to avoid all that processing right in the interrupt hot
path and just store the raw data for later processing?

Thanks,

	tglx

     
```
