From: Alex Markuze Date: Thu, 18 Sep 2025 08:42:27 +0000 (+0000) Subject: sched: add per-task BLOG context slots X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f3fab931c49befa3de8f3d0ebea602e59bf9fbf2;p=ceph-client.git sched: add per-task BLOG context slots --- diff --git a/include/linux/sched.h b/include/linux/sched.h index f96ac1982893..533835ca81d6 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1274,6 +1274,14 @@ struct task_struct { /* Journalling filesystem info: */ void *journal_info; +/* BLOG support - max modules defined here for use by other headers */ +#define BLOG_MAX_MODULES 8 + +#if defined(CONFIG_BLOG) || defined(CONFIG_BLOG_MODULE) + struct blog_tls_ctx *blog_contexts[BLOG_MAX_MODULES]; + u8 blog_ctx_bitmap; +#endif + /* Stacked block device info: */ struct bio_list *bio_list; diff --git a/kernel/fork.c b/kernel/fork.c index 168681fc4b25..d1c6cc74515d 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -24,6 +24,9 @@ #include #include #include +#if defined(CONFIG_BLOG) || defined(CONFIG_BLOG_MODULE) +#include +#endif #include #include #include @@ -180,8 +183,34 @@ static inline struct task_struct *alloc_task_struct_node(int node) return kmem_cache_alloc_node(task_struct_cachep, GFP_KERNEL, node); } +struct tls_storage { + void (*release)(void *state); +}; + static inline void free_task_struct(struct task_struct *tsk) { +/* + if (tsk->tls.release) { + tsk->tls.release(tsk->tls.state); + tsk->tls.state = NULL; + tsk->tls.release = NULL; + } +*/ +#if defined(CONFIG_BLOG) || defined(CONFIG_BLOG_MODULE) + /* Clean up any BLOG contexts */ + { + int i; + for (i = 0; i < BLOG_MAX_MODULES; i++) { + if (tsk->blog_contexts[i]) { + struct blog_tls_ctx *ctx = tsk->blog_contexts[i]; + if (ctx->release) + ctx->release(ctx); + tsk->blog_contexts[i] = NULL; + } + } + tsk->blog_ctx_bitmap = 0; + } +#endif kmem_cache_free(task_struct_cachep, tsk); } @@ -2260,6 +2289,17 @@ __latent_entropy struct task_struct *copy_process( p = dup_task_struct(current, node); if (!p) goto fork_out; + +#if defined(CONFIG_BLOG) || defined(CONFIG_BLOG_MODULE) + /* Initialize BLOG contexts */ + { + int i; + for (i = 0; i < BLOG_MAX_MODULES; i++) + p->blog_contexts[i] = NULL; + p->blog_ctx_bitmap = 0; + } +#endif + p->flags &= ~PF_KTHREAD; if (args->kthread) p->flags |= PF_KTHREAD;