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 17/22] coredump: describe the holes when COREDUMP_SPARSE is negotiated
Date: Wed, 9 Sep 2026 21:34:47 +0530 [thread overview]
Message-ID: <119b7dab-7eda-4e7e-95c2-a16d975ce8c2@linux.ibm.com> (raw)
In-Reply-To: <20260820-work-coredump-sparse-v2-17-ba32dd718c51@kernel.org>
On 20.08.2026 4:39 AM, Christian Brauner wrote:
> Make use of COREDUMP_SPARSE. Refuse it without COREDUMP_RECORDS.
>
> Actual holes are sent as a record with length indicating how much zero
> data there was.
>
> coredump_write() flushes a trailing hole if the coredump is done.
> Instead of writing the actual byte for pipes and sockets, collapse it.
> This stops wasting a header with coredump records for a single byte. So
> we now only write it when the coredump can be seeked. TL;DR a trailing
> hole is a zero record like any other and the records still cover the
> whole coredump.
>
> 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 | 41 +++++++++++++++++-----
> .../selftests/coredump/coredump_test_helpers.c | 3 +-
> 2 files changed, 35 insertions(+), 9 deletions(-)
>
> diff --git a/fs/coredump.c b/fs/coredump.c
> index b1679930094c..7b568d25887c 100644
> --- a/fs/coredump.c
> +++ b/fs/coredump.c
> @@ -68,6 +68,7 @@
> static bool dump_vma_snapshot(struct coredump_params *cprm);
> static void free_vma_snapshot(struct coredump_params *cprm);
> static void dump_end_record(struct coredump_params *cprm);
> +static bool dump_flush_skip(struct coredump_params *cprm);
>
> #define CORE_FILE_NOTE_SIZE_DEFAULT (4*1024*1024)
> /* Define a reasonable max cap */
> @@ -806,7 +807,7 @@ static bool coredump_sock_request(struct core_name *cn, struct coredump_params *
> .size = sizeof(struct coredump_req),
> .mask = COREDUMP_KERNEL | COREDUMP_USERSPACE |
> COREDUMP_REJECT | COREDUMP_WAIT |
> - COREDUMP_RECORDS,
> + COREDUMP_RECORDS | COREDUMP_SPARSE,
> .size_ack = sizeof(struct coredump_ack),
> };
> struct coredump_ack ack = {};
> @@ -866,6 +867,12 @@ static bool coredump_sock_request(struct core_name *cn, struct coredump_params *
> return false;
> }
>
> + /* Zero records only exist inside a record stream. */
> + if ((ack.mask & COREDUMP_SPARSE) && !(ack.mask & COREDUMP_RECORDS)) {
> + coredump_sock_mark(cprm->file, COREDUMP_MARK_CONFLICTING);
> + return false;
> + }
> +
> /* Record header scratch; a bvec can't point at the stack. */
> if (ack.mask & COREDUMP_RECORDS) {
> cprm->record_hdr = kmalloc_obj(*cprm->record_hdr);
> @@ -1076,15 +1083,21 @@ static bool coredump_write(struct coredump_params *cprm,
> if (!binfmt->core_dump(cprm))
> cprm->state |= COREDUMP_STATE_TRUNCATED;
> /*
> - * Ensures that file size is big enough to contain the current
> - * file position. This prevents gdb from complaining about
> - * a truncated file if the last "write" to the file was
> - * dump_skip. A record stream relies on it too: the flush
> - * emits the records that cover a trailing hole.
> + * A trailing hole still has to land in the coredump. Seeking over
> + * it doesn't grow the file, so the last byte of it is written
> + * instead and gdb doesn't see a truncated file. Everything else
> + * puts the hole on the wire as it flushes it.
> */
> if (cprm->to_skip) {
> - cprm->to_skip--;
> - if (!dump_emit(cprm, "", 1))
> + bool flushed;
> +
> + if (cprm->file->f_mode & FMODE_LSEEK) {
> + cprm->to_skip--;
> + flushed = dump_emit(cprm, "", 1);
> + } else {
> + flushed = dump_flush_skip(cprm);
> + }
> + if (!flushed)
> cprm->state |= COREDUMP_STATE_TRUNCATED;
> }
> dump_end_record(cprm);
> @@ -1241,6 +1254,11 @@ static bool dump_records(const struct coredump_params *cprm)
> return cprm->mask & COREDUMP_RECORDS;
> }
>
> +static bool dump_sparse(const struct coredump_params *cprm)
> +{
> + return cprm->mask & COREDUMP_SPARSE;
> +}
> +
> /* Describe the next @len bytes of the coredump. Returns the header size. */
> static size_t dump_record_init(struct coredump_params *cprm,
> enum coredump_record_type type, u64 flags,
> @@ -1357,6 +1375,13 @@ static bool __dump_skip(struct coredump_params *cprm, size_t nr)
> static char zeroes[PAGE_SIZE];
> struct file *file = cprm->file;
>
> + if (dump_sparse(cprm)) {
> + /* Hand the server the length of the hole instead of the hole itself. */
> + if (dump_interrupted())
> + return false;
> + return dump_emit_record(cprm, COREDUMP_RECORD_ZERO, 0, nr);
> + }
> +
> if (file->f_mode & FMODE_LSEEK) {
> if (dump_interrupted() || vfs_llseek(file, nr, SEEK_CUR) < 0)
> return false;
> diff --git a/tools/testing/selftests/coredump/coredump_test_helpers.c b/tools/testing/selftests/coredump/coredump_test_helpers.c
> index 1c8658f35735..a5b9cde47239 100644
> --- a/tools/testing/selftests/coredump/coredump_test_helpers.c
> +++ b/tools/testing/selftests/coredump/coredump_test_helpers.c
> @@ -275,7 +275,8 @@ bool send_coredump_ack(int fd, const struct coredump_req *req,
> /* Every option the kernel is expected to advertise in coredump_req->mask. */
> #define TEST_REQ_MASK_ALL \
> (COREDUMP_KERNEL | COREDUMP_USERSPACE | \
> - COREDUMP_REJECT | COREDUMP_WAIT | COREDUMP_RECORDS)
> + COREDUMP_REJECT | COREDUMP_WAIT | \
> + COREDUMP_RECORDS | COREDUMP_SPARSE)
>
> bool check_coredump_req(const struct coredump_req *req)
> {
>
--
Thanks and Regards
R.Nageswara Sastry
next prev parent reply other threads:[~2026-09-09 16:05 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
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 [this message]
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=119b7dab-7eda-4e7e-95c2-a16d975ce8c2@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®