lkml.org 
[lkml]   [2020]   [Apr]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/1] rcu/tree: add emergency pool for headless case
On Fri, Apr 03, 2020 at 07:30:51PM +0200, Uladzislau Rezki (Sony) wrote:
> @@ -2877,6 +2885,12 @@ struct kfree_rcu_cpu {
> bool initialized;
> // Number of objects for which GP not started
> int count;
> +
> + /*
> + * Reserved emergency pool for headless variant.
> + */
> + int nr_emergency;
> + void **emergency;

This is a pretty expensive way to maintain an emergency pool.

Try something like this ...

struct emergency_pool_object {
union {
struct whatever foo;
struct {
int remaining;
void *next;
};
};
};

struct kfree_rcu_cpu {
...
struct emergency_pool_object *epo;
};

struct whatever *get_emergency_object(struct kfree_rcu_cpu *krc)
{
struct emergency_pool_object *epo = krc->epo;
if (epo)
krc->epo = epo->next;
return &epo->foo;
}

void alloc_emergency_objects(struct kfree_rcu_cpu *krc, int n)
{
int i = 0;

if (krc->epo)
i = krc->epo->remaining;

while (++i < n) {
struct emergency_pool_object *epo = kmalloc(sizeof(epo), GFP);
epo->remaining = i;
epo->next = krc->epo;
krc->epo = epo;
}
}

\
 
 \ /
  Last update: 2020-04-03 20:17    [W:0.311 / U:0.084 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site