All of lore.kernel.org
 help / color / mirror / Atom feed
* Can we get a general timed LRU built on the workqueue subsys?
@ 2021-06-08 15:14 David Howells
  2021-06-16 15:50 ` Tejun Heo
  0 siblings, 1 reply; 2+ messages in thread
From: David Howells @ 2021-06-08 15:14 UTC (permalink / raw)
  To: Tejun Heo, Lai Jiangshan; +Cc: dhowells, Peter Zijlstra, linux-kernel

Hi Tejun,

Would it be practical to get some sort of timed LRU built on top of the
workqueue such that I can, say, queue an item on it without using the
delayed_work struct?

The reason I'd like this is that I want to avoid using delayed_work because it
would increase the size of the fscache_cookie struct by 50% (110% with
lockdep), and then you'd have to multiply that by the number of cookies on the
system - could be tens or hundreds of thousands; could be a million+ in some
applications.

Really, only one timer should be necessary for the entire queue if every item
in the queue has the same timeout length, since it would only need to keep
track of the item at the front of the queue.  This timer could be managed with
timer_reduce() rather than mod_timer() or del_timer()+add_timer().

Each item in the queue would need a timestamp to say when it expires, say:

	struct work_lru {
		struct work_struct work;
		unsigned long expires_at;
	};

There are other places I could use such a thing too, not just for fscache
cookies.

David


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

* Re: Can we get a general timed LRU built on the workqueue subsys?
  2021-06-08 15:14 Can we get a general timed LRU built on the workqueue subsys? David Howells
@ 2021-06-16 15:50 ` Tejun Heo
  0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2021-06-16 15:50 UTC (permalink / raw)
  To: David Howells; +Cc: Lai Jiangshan, Peter Zijlstra, linux-kernel

Hello, David.

On Tue, Jun 08, 2021 at 04:14:21PM +0100, David Howells wrote:
> Would it be practical to get some sort of timed LRU built on top of the
> workqueue such that I can, say, queue an item on it without using the
> delayed_work struct?
> 
> The reason I'd like this is that I want to avoid using delayed_work because it
> would increase the size of the fscache_cookie struct by 50% (110% with
> lockdep), and then you'd have to multiply that by the number of cookies on the
> system - could be tens or hundreds of thousands; could be a million+ in some
> applications.
> 
> Really, only one timer should be necessary for the entire queue if every item
> in the queue has the same timeout length, since it would only need to keep
> track of the item at the front of the queue.  This timer could be managed with
> timer_reduce() rather than mod_timer() or del_timer()+add_timer().
> 
> Each item in the queue would need a timestamp to say when it expires, say:
> 
> 	struct work_lru {
> 		struct work_struct work;
> 		unsigned long expires_at;
> 	};
> 
> There are other places I could use such a thing too, not just for fscache
> cookies.

No objection from me but if reducing the size of delayed_work is meaningful
enough I kinda wonder whether this can be generalized so that all
delayed_works are smaller. There's no fundmental reason to have these
smaller ones separate, right?

Thanks.

-- 
tejun

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

end of thread, other threads:[~2021-06-16 15:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-08 15:14 Can we get a general timed LRU built on the workqueue subsys? David Howells
2021-06-16 15:50 ` Tejun Heo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.