linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Alex Markuze <amarkuze@redhat.com>
Cc: ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, Liam.Howlett@oracle.com,
	akpm@linux-foundation.org, bsegall@google.com, david@redhat.com,
	dietmar.eggemann@arm.com, idryomov@gmail.com, mingo@redhat.com,
	juri.lelli@redhat.com, kees@kernel.org,
	lorenzo.stoakes@oracle.com, mgorman@suse.de, mhocko@suse.com,
	rppt@kernel.org, peterz@infradead.org, surenb@google.com,
	vschneid@redhat.com, vincent.guittot@linaro.org, vbabka@suse.cz,
	xiubli@redhat.com, Slava.Dubeyko@ibm.com
Subject: Re: [RFC PATCH 1/5] sched, fork: Wire BLOG contexts into task lifecycle
Date: Fri, 24 Oct 2025 13:44:09 -0400	[thread overview]
Message-ID: <20251024134409.72275dd4@gandalf.local.home> (raw)
In-Reply-To: <20251024084259.2359693-2-amarkuze@redhat.com>



On Fri, 24 Oct 2025 08:42:55 +0000
Alex Markuze <amarkuze@redhat.com> wrote:

> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index 07576479c0ed..e381f8421a11 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -1278,6 +1278,13 @@ 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
> +
> +#ifdef CONFIG_BLOG
> +	struct blog_tls_ctx		*blog_contexts[BLOG_MAX_MODULES];
> +#endif
> +
>  	/* Stacked block device info: */
>  	struct bio_list			*bio_list;
>  
> diff --git a/kernel/fork.c b/kernel/fork.c
> index 3da0f08615a9..b06843af05a9 100644
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -24,6 +24,9 @@
>  #include <linux/sched/cputime.h>
>  #include <linux/sched/ext.h>
>  #include <linux/seq_file.h>
> +#ifdef CONFIG_BLOG
> +#include <linux/blog/blog.h>
> +#endif

The proper way to do this is to have the #ifdef in the header file and not
in the C file.

>  #include <linux/rtmutex.h>
>  #include <linux/init.h>
>  #include <linux/unistd.h>
> @@ -186,6 +189,29 @@ static inline struct task_struct *alloc_task_struct_node(int node)
>  
>  static inline void free_task_struct(struct task_struct *tsk)
>  {
> +#ifdef CONFIG_BLOG
> +	/* Clean up any BLOG contexts */
> +	{

There should be a function that gets called here that frees up the context.
This does not belong in the fork.c file.

	blog_free(task);

In the header file have:

#ifdef CONFIG_BLOG
[..]
void blog_free(struct task_struct *task);
#else
static inline blog_free(struct task_struct *task)
{
}
#endif /* CONFIG_BLOG */



> +		struct blog_tls_ctx *contexts[BLOG_MAX_MODULES];
> +		int i;
> +
> +		/* Step 1: Atomically detach all contexts while holding lock */
> +		task_lock(tsk);
> +		for (i = 0; i < BLOG_MAX_MODULES; i++) {
> +			contexts[i] = tsk->blog_contexts[i];
> +			tsk->blog_contexts[i] = NULL;
> +		}
> +		task_unlock(tsk);
> +
> +		/* Step 2: Release contexts outside the lock */
> +		for (i = 0; i < BLOG_MAX_MODULES; i++) {
> +			struct blog_tls_ctx *ctx = contexts[i];
> +
> +			if (ctx && ctx->release)
> +				ctx->release(ctx);
> +		}
> +	}
> +#endif
>  	kmem_cache_free(task_struct_cachep, tsk);
>  }
>  
> @@ -2012,6 +2038,17 @@ __latent_entropy struct task_struct *copy_process(
>  	p = dup_task_struct(current, node);
>  	if (!p)
>  		goto fork_out;
> +
> +#ifdef CONFIG_BLOG
> +	/* Initialize BLOG contexts */
> +	{
> +		int i;
> +
> +		for (i = 0; i < BLOG_MAX_MODULES; i++)
> +			p->blog_contexts[i] = NULL;
> +	}
> +#endif

Same here.

> +
>  	p->flags &= ~PF_KTHREAD;
>  	if (args->kthread)
>  		p->flags |= PF_KTHREAD;

-- Steve



  reply	other threads:[~2025-10-24 17:43 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-24  8:42 [RFC PATCH 0/5] BLOG: per-task logging contexts with Ceph consumer Alex Markuze
2025-10-24  8:42 ` [RFC PATCH 1/5] sched, fork: Wire BLOG contexts into task lifecycle Alex Markuze
2025-10-24 17:44   ` Steven Rostedt [this message]
2025-10-29 18:57   ` Viacheslav Dubeyko
2025-10-24  8:42 ` [RFC PATCH 2/5] lib: Introduce BLOG (Binary LOGging) subsystem Alex Markuze
2025-10-30 18:47   ` Viacheslav Dubeyko
2025-10-24  8:42 ` [RFC PATCH 3/5] ceph: Add BLOG scaffolding Alex Markuze
2025-11-03 22:37   ` Viacheslav Dubeyko
2025-10-24  8:42 ` [RFC PATCH 4/5] ceph: Add BLOG debugfs support Alex Markuze
2025-11-03 21:07   ` Viacheslav Dubeyko
2025-10-24  8:42 ` [RFC PATCH 5/5] ceph: Activate BLOG logging Alex Markuze
2025-11-03 21:00   ` Viacheslav Dubeyko
2025-10-24 15:32 ` [RFC PATCH 0/5] BLOG: per-task logging contexts with Ceph consumer David Hildenbrand
2025-10-24 17:53 ` Steven Rostedt
2025-10-25 10:50   ` Alex Markuze
2025-10-25 14:59     ` Steven Rostedt
2025-10-25 17:54       ` Alex Markuze
2025-10-27 14:54         ` Steven Rostedt
2025-10-28 17:07 ` Viacheslav Dubeyko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251024134409.72275dd4@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=Liam.Howlett@oracle.com \
    --cc=Slava.Dubeyko@ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=amarkuze@redhat.com \
    --cc=bsegall@google.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=david@redhat.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=idryomov@gmail.com \
    --cc=juri.lelli@redhat.com \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=mgorman@suse.de \
    --cc=mhocko@suse.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rppt@kernel.org \
    --cc=surenb@google.com \
    --cc=vbabka@suse.cz \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    --cc=xiubli@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox