qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: Jon Wilson <jonwilson030981@googlemail.com>, qemu-devel@nongnu.org
Cc: Laurent Vivier <laurent@vivier.eu>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Jon Wilson <jonwilson030981@gmail.com>
Subject: Re: [PATCH v4] Support madvise(MADV_DONTDUMP) when creating core dumps for qemu-user
Date: Thu, 10 Jul 2025 13:48:18 -0600	[thread overview]
Message-ID: <eaeb838a-6211-44f1-afca-4d94eb24c170@linaro.org> (raw)
In-Reply-To: <20250506173423.1312788-1-jonwilson030981@gmail.com>

On 5/6/25 11:34, Jon Wilson wrote:
> +    case MADV_DONTDUMP:
> +        if (len > 0) {
> +            /*
> +             * To set the page permissons, we must OR our new flags with the
> +             * existing flags. Only mark the pages as PAGE_DONTDUMP if the
> +             * entire range has the same flags. If any part of the range
> +             * differs, we would need to process it one page at a time which
> +             * might not be very performant. Since we are not obliged to respect
> +             * this flag, we will support it for the most likely usage scenario.
> +             * Note that we don't set PAGE_ANON, since this can only be set with
> +             * new mappings.
> +             */
> +            int flg = page_get_flags(start);
> +            if (page_check_range(start, len, flg)) {
> +                page_set_flags(start, start + len - 1, PAGE_DONTDUMP | (flg & ~PAGE_ANON) );
> +            }

There is an existing helper function, pageflags_set_clear, which could be promoted and 
exported to perform this OR.  Indeed, the bits-to-set and bits-to-clear interface would 
probably be clearer for all existing uses of page_set_flags, eliminating the need for the 
PAGE_RESET hack.

You don't want to clear PAGE_ANON.


r~


      reply	other threads:[~2025-07-10 19:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-06 17:34 [PATCH v4] Support madvise(MADV_DONTDUMP) when creating core dumps for qemu-user Jon Wilson
2025-07-10 19:48 ` Richard Henderson [this message]

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=eaeb838a-6211-44f1-afca-4d94eb24c170@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=jonwilson030981@gmail.com \
    --cc=jonwilson030981@googlemail.com \
    --cc=laurent@vivier.eu \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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;
as well as URLs for NNTP newsgroup(s).