mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: R Nageswara Sastry <rnsastry@linux.ibm.com>
To: Christian Brauner <brauner@kernel.org>, linux-fsdevel@vger.kernel.org
Cc: Jacob Lalonde <jalalonde@meta.com>,
	Josef Bacik <josef@toxicpanda.com>, Jann Horn <jannh@google.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>, Jan Kara <jack@suse.cz>,
	Andrew Morton <akpm@linux-foundation.org>,
	David Hildenbrand <david@kernel.org>,
	Lorenzo Stoakes <ljs@kernel.org>,
	"Liam R. Howlett" <liam@infradead.org>,
	Vlastimil Babka <vbabka@kernel.org>,
	Mike Rapoport <rppt@kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	Michal Hocko <mhocko@suse.com>,
	Omar Sandoval <osandov@osandov.com>,
	Jacob Lalonde <jalalonde@fb.com>, Shuah Khan <shuah@kernel.org>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	linux-kselftest@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v2 10/22] coredump: make the dump helper return bool
Date: Wed, 9 Sep 2026 21:29:39 +0530	[thread overview]
Message-ID: <3f441c3d-79fd-4d38-870a-717bb966524f@linux.ibm.com> (raw)
In-Reply-To: <20260820-work-coredump-sparse-v2-10-ba32dd718c51@kernel.org>


On 20.08.2026 4:39 AM, Christian Brauner wrote:
> The various dump helpers return one and zero. Every caller just does a
> boolean test. Convert them to return an actual bool.
>
> While at it, drop the externs.
>
> No functional changes.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Tested-by: R Nageswara Sastry <rnsastry@linux.ibm.com>

System: ppc64le LPAR (IBM POWER), Linux 7.3-rc2
> ---
>   fs/coredump.c            | 63 ++++++++++++++++++++++++------------------------
>   include/linux/coredump.h | 14 +++++------
>   2 files changed, 39 insertions(+), 38 deletions(-)
>
> diff --git a/fs/coredump.c b/fs/coredump.c
> index cd36a72be445..d837819031ff 100644
> --- a/fs/coredump.c
> +++ b/fs/coredump.c
> @@ -1215,41 +1215,41 @@ void vfs_coredump(const kernel_siginfo_t *siginfo)
>    * do on a core-file: use only these functions to write out all the
>    * necessary info.
>    */
> -static int __dump_emit(struct coredump_params *cprm, const void *addr, int nr)
> +static bool __dump_emit(struct coredump_params *cprm, const void *addr, int nr)
>   {
>   	struct file *file = cprm->file;
>   	loff_t pos = file->f_pos;
>   	ssize_t n;
>   
>   	if (cprm->written + nr > cprm->limit)
> -		return 0;
> +		return false;
>   	if (dump_interrupted())
> -		return 0;
> +		return false;
>   	n = __kernel_write(file, addr, nr, &pos);
>   	if (n != nr)
> -		return 0;
> +		return false;
>   	file->f_pos = pos;
>   	cprm->written += n;
>   	cprm->pos += n;
>   
> -	return 1;
> +	return true;
>   }
>   
> -static int __dump_skip(struct coredump_params *cprm, size_t nr)
> +static bool __dump_skip(struct coredump_params *cprm, size_t nr)
>   {
>   	static char zeroes[PAGE_SIZE];
>   	struct file *file = cprm->file;
>   
>   	if (file->f_mode & FMODE_LSEEK) {
>   		if (dump_interrupted() || vfs_llseek(file, nr, SEEK_CUR) < 0)
> -			return 0;
> +			return false;
>   		cprm->pos += nr;
> -		return 1;
> +		return true;
>   	}
>   
>   	while (nr > PAGE_SIZE) {
>   		if (!__dump_emit(cprm, zeroes, PAGE_SIZE))
> -			return 0;
> +			return false;
>   		nr -= PAGE_SIZE;
>   	}
>   
> @@ -1257,20 +1257,20 @@ static int __dump_skip(struct coredump_params *cprm, size_t nr)
>   }
>   
>   /* Flush the accumulated hole before writing data. */
> -static int dump_flush_skip(struct coredump_params *cprm)
> +static bool dump_flush_skip(struct coredump_params *cprm)
>   {
>   	if (cprm->to_skip) {
>   		if (!__dump_skip(cprm, cprm->to_skip))
> -			return 0;
> +			return false;
>   		cprm->to_skip = 0;
>   	}
> -	return 1;
> +	return true;
>   }
>   
> -int dump_emit(struct coredump_params *cprm, const void *addr, int nr)
> +bool dump_emit(struct coredump_params *cprm, const void *addr, int nr)
>   {
>   	if (!dump_flush_skip(cprm))
> -		return 0;
> +		return false;
>   	return __dump_emit(cprm, addr, nr);
>   }
>   EXPORT_SYMBOL(dump_emit);
> @@ -1290,7 +1290,7 @@ void dump_skip(struct coredump_params *cprm, size_t nr)
>   EXPORT_SYMBOL(dump_skip);
>   
>   #ifdef CONFIG_ELF_CORE
> -static int dump_emit_page(struct coredump_params *cprm, struct page *page)
> +static bool dump_emit_page(struct coredump_params *cprm, struct page *page)
>   {
>   	struct bio_vec bvec;
>   	struct iov_iter iter;
> @@ -1299,25 +1299,25 @@ static int dump_emit_page(struct coredump_params *cprm, struct page *page)
>   	ssize_t n;
>   
>   	if (!page)
> -		return 0;
> +		return false;
>   
>   	if (!dump_flush_skip(cprm))
> -		return 0;
> +		return false;
>   	if (cprm->written + PAGE_SIZE > cprm->limit)
> -		return 0;
> +		return false;
>   	if (dump_interrupted())
> -		return 0;
> +		return false;
>   	pos = file->f_pos;
>   	bvec_set_page(&bvec, page, PAGE_SIZE, 0);
>   	iov_iter_bvec(&iter, ITER_SOURCE, &bvec, 1, PAGE_SIZE);
>   	n = __kernel_write_iter(cprm->file, &iter, &pos);
>   	if (n != PAGE_SIZE)
> -		return 0;
> +		return false;
>   	file->f_pos = pos;
>   	cprm->written += PAGE_SIZE;
>   	cprm->pos += PAGE_SIZE;
>   
> -	return 1;
> +	return true;
>   }
>   
>   /*
> @@ -1349,18 +1349,19 @@ static inline struct page *dump_page_copy(struct page *src, struct page *dst)
>   }
>   #endif
>   
> -int dump_user_range(struct coredump_params *cprm, unsigned long start,
> -		    unsigned long len)
> +bool dump_user_range(struct coredump_params *cprm, unsigned long start,
> +		     unsigned long len)
>   {
>   	unsigned long addr;
>   	struct page *dump_page;
> -	int locked, ret;
> +	int locked;
> +	bool ret;
>   
>   	dump_page = dump_page_alloc();
>   	if (!dump_page)
> -		return 0;
> +		return false;
>   
> -	ret = 0;
> +	ret = false;
>   	locked = 0;
>   	for (addr = start; addr < start + len; addr += PAGE_SIZE) {
>   		struct page *page;
> @@ -1384,7 +1385,7 @@ int dump_user_range(struct coredump_params *cprm, unsigned long start,
>   				mmap_read_unlock(current->mm);
>   				locked = 0;
>   			}
> -			int stop = !dump_emit_page(cprm, dump_page_copy(page, dump_page));
> +			bool stop = !dump_emit_page(cprm, dump_page_copy(page, dump_page));
>   			put_page(page);
>   			if (stop)
>   				goto out;
> @@ -1403,7 +1404,7 @@ int dump_user_range(struct coredump_params *cprm, unsigned long start,
>   		}
>   		cond_resched();
>   	}
> -	ret = 1;
> +	ret = true;
>   out:
>   	if (locked)
>   		mmap_read_unlock(current->mm);
> @@ -1413,14 +1414,14 @@ int dump_user_range(struct coredump_params *cprm, unsigned long start,
>   }
>   #endif
>   
> -int dump_align(struct coredump_params *cprm, int align)
> +bool dump_align(struct coredump_params *cprm, int align)
>   {
>   	unsigned mod = (cprm->pos + cprm->to_skip) & (align - 1);
>   	if (align & (align - 1))
> -		return 0;
> +		return false;
>   	if (mod)
>   		cprm->to_skip += align - mod;
> -	return 1;
> +	return true;
>   }
>   EXPORT_SYMBOL(dump_align);
>   
> diff --git a/include/linux/coredump.h b/include/linux/coredump.h
> index dc7a05b1bb0a..943bddfb22bf 100644
> --- a/include/linux/coredump.h
> +++ b/include/linux/coredump.h
> @@ -43,13 +43,13 @@ extern unsigned int core_file_note_size_limit;
>    * These are the only things you should do on a core-file: use only these
>    * functions to write out all the necessary info.
>    */
> -extern void dump_skip_to(struct coredump_params *cprm, unsigned long to);
> -extern void dump_skip(struct coredump_params *cprm, size_t nr);
> -extern int dump_emit(struct coredump_params *cprm, const void *addr, int nr);
> -extern int dump_align(struct coredump_params *cprm, int align);
> -int dump_user_range(struct coredump_params *cprm, unsigned long start,
> -		    unsigned long len);
> -extern void vfs_coredump(const kernel_siginfo_t *siginfo);
> +void dump_skip_to(struct coredump_params *cprm, unsigned long to);
> +void dump_skip(struct coredump_params *cprm, size_t nr);
> +bool dump_emit(struct coredump_params *cprm, const void *addr, int nr);
> +bool dump_align(struct coredump_params *cprm, int align);
> +bool dump_user_range(struct coredump_params *cprm, unsigned long start,
> +		     unsigned long len);
> +void vfs_coredump(const kernel_siginfo_t *siginfo);
>   
>   /*
>    * Logging for the coredump code, ratelimited.
>
-- 
Thanks and Regards
R.Nageswara Sastry


  reply	other threads:[~2026-09-09 16:00 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-19 23:09 [PATCH v2 00/22] coredump: allow to create sparse coredumps on the coredump socket Christian Brauner
2026-08-19 23:09 ` [PATCH v2 01/22] powerpc/spufs: don't dump more than the note supports Christian Brauner
2026-09-09 15:52   ` R Nageswara Sastry
2026-08-19 23:09 ` [PATCH v2 02/22] coredump: refuse negative skips Christian Brauner
2026-09-09 15:53   ` R Nageswara Sastry
2026-08-19 23:09 ` [PATCH v2 03/22] coredump: set the minimum send buffer size Christian Brauner
2026-09-09 15:53   ` R Nageswara Sastry
2026-08-19 23:09 ` [PATCH v2 04/22] selftests/coredump: discard the right amount after the coredump request Christian Brauner
2026-09-09 15:54   ` R Nageswara Sastry
2026-08-19 23:09 ` [PATCH v2 05/22] selftests/coredump: collapse the expected request check into the helper Christian Brauner
2026-09-09 15:54   ` R Nageswara Sastry
2026-08-19 23:09 ` [PATCH v2 06/22] selftests/coredump: add a separate helper header Christian Brauner
2026-09-09 15:55   ` R Nageswara Sastry
2026-08-19 23:09 ` [PATCH v2 07/22] coredump: pin the protocol struct sizes Christian Brauner
2026-09-09 15:55   ` R Nageswara Sastry
2026-08-19 23:09 ` [PATCH v2 08/22] coredump: move the negotiated mask into struct coredump_params Christian Brauner
2026-09-09 15:56   ` R Nageswara Sastry
2026-08-19 23:09 ` [PATCH v2 09/22] coredump: deduplicate the to_skip flush Christian Brauner
2026-09-09 15:56   ` R Nageswara Sastry
2026-08-19 23:09 ` [PATCH v2 10/22] coredump: make the dump helper return bool Christian Brauner
2026-09-09 15:59   ` R Nageswara Sastry [this message]
2026-08-19 23:09 ` [PATCH v2 11/22] coredump: always chunk writes Christian Brauner
2026-09-09 16:00   ` R Nageswara Sastry
2026-08-19 23:09 ` [PATCH v2 12/22] coredump: clean up coredump state handling Christian Brauner
2026-09-09 16:01   ` R Nageswara Sastry
2026-08-19 23:09 ` [PATCH v2 13/22] coredump: add COREDUMP_RECORDS to the coredump socket protocol Christian Brauner
2026-09-09 16:02   ` R Nageswara Sastry
2026-08-19 23:09 ` [PATCH v2 14/22] coredump: add COREDUMP_SPARSE " Christian Brauner
2026-09-09 16:02   ` R Nageswara Sastry
2026-08-19 23:09 ` [PATCH v2 15/22] tools: sync coredump.h header Christian Brauner
2026-09-09 16:03   ` R Nageswara Sastry
2026-08-19 23:09 ` [PATCH v2 16/22] coredump: send the coredump in records if requested Christian Brauner
2026-09-09 16:04   ` R Nageswara Sastry
2026-08-19 23:09 ` [PATCH v2 17/22] coredump: describe the holes when COREDUMP_SPARSE is negotiated Christian Brauner
2026-09-09 16:04   ` R Nageswara Sastry
2026-09-09 16:21   ` David Hildenbrand (Arm)
2026-08-19 23:09 ` [PATCH v2 18/22] selftests/coredump: test COREDUMP_RECORDS and COREDUMP_SPARSE Christian Brauner
2026-09-09 16:05   ` R Nageswara Sastry
2026-08-19 23:09 ` [PATCH v2 19/22] selftests/coredump: hand the record stream to a sink Christian Brauner
2026-09-09 16:05   ` R Nageswara Sastry
2026-08-19 23:09 ` [PATCH v2 20/22] selftests/coredump: put a hole in the middle of a sparse mapping Christian Brauner
2026-09-09 16:06   ` R Nageswara Sastry
2026-09-09 16:18   ` David Hildenbrand (Arm)
2026-08-19 23:09 ` [PATCH v2 21/22] selftests/coredump: simulate a blob store Christian Brauner
2026-09-09 16:06   ` R Nageswara Sastry
2026-08-19 23:09 ` [PATCH v2 22/22] selftests/coredump: show how to inspect the task to decide how the coredump should be sent Christian Brauner
2026-09-09 16:07   ` R Nageswara Sastry

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=3f441c3d-79fd-4d38-870a-717bb966524f@linux.ibm.com \
    --to=rnsastry@linux.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=brauner@kernel.org \
    --cc=david@kernel.org \
    --cc=jack@suse.cz \
    --cc=jalalonde@fb.com \
    --cc=jalalonde@meta.com \
    --cc=jannh@google.com \
    --cc=josef@toxicpanda.com \
    --cc=liam@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=osandov@osandov.com \
    --cc=rppt@kernel.org \
    --cc=shuah@kernel.org \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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

all inboxes | Powered by JetHome®