mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Anshuman Khandual <anshuman.khandual@arm.com>,
	linux-arm-kernel@lists.infradead.org
Cc: mark.rutland@arm.com, Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Ryan Roberts <ryan.roberts@arm.com>,
	Yang Shi <yang@os.amperecomputing.com>,
	Christoph Lameter <cl@gentwo.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH V3 2/2] arm64/mm: Reject memory removal that splits a kernel leaf mapping
Date: Tue, 3 Mar 2026 10:00:49 +0100	[thread overview]
Message-ID: <05e6034d-3493-4961-a97d-a80fff78289b@kernel.org> (raw)
In-Reply-To: <2d07e814-a7a3-4cec-8a59-158420bde1f2@arm.com>

>> I can understand the desire for this check, but I am confused about Fixes:
> 
> Probably nothing is broken now I guess but the original memory hot remove
> patch should have taken care of this scenario. Although don't have strong
> opinions either way. We could drop both "Fixes" and "Closes" tags here if
> that is preferred.
> 

We tend to only tag actual fixes. If we consider this a possible fix, we
should ask ourselves whether this would be stable material.

...

>>> +		return false;
>>> +
>>> +	pgdp = pgd_offset_k(addr);
>>> +	pgd = pgdp_get(pgdp);
>>> +	if (!pgd_present(pgd))
>>> +		return false;
>>
>> How could we end up with non-present areas in a range we hotplugged earlier?
> 
> We might not in reality but in order to be sure just an additional protection.

I'm rather wondering if this would indicate a real bug somewhere else
that we would silently swallow.

Anyhow, no real preference from my side, just something I considered weird.

[...]

>>> +
>>> +static bool can_unmap_without_split(unsigned long pfn, unsigned long nr_pages)
>>> +{
>>> +	unsigned long phys_start, phys_end, size, start, end;
>>> +
>>> +	phys_start = PFN_PHYS(pfn);
>>> +	phys_end = phys_start + nr_pages * PAGE_SIZE;
>>> +
>>> +	/*
>>> +	 * PFN range's linear map edges are leaf entry aligned
>>> +	 */
>>> +	start = __phys_to_virt(phys_start);
>>> +	end =  __phys_to_virt(phys_end);
>>> +	if (addr_splits_kernel_leaf(start) || addr_splits_kernel_leaf(end)) {
>>> +		pr_warn("[%lx %lx] splits a leaf entry in linear map\n",
>>> +			phys_start, phys_end);
>>> +		return false;
>>> +	}
>>> +
>>> +	/*
>>> +	 * PFN range's vmemmap edges are leaf entry aligned
>>> +	 */
>>> +	size = nr_pages * sizeof(struct page);
>>> +	start = (unsigned long)pfn_to_page(pfn);
>>> +	end = start + size;
>>
>> As arm64 cannot be used with CONFIG_SPARSEMEM (only with
>> CONFIG_SPARSEMEM_VMEMMAP, as it sets SPARSEMEM_VMEMMAP_ENABLE),
>> I think you can just do

Just to clarify:

What I meant here is: with CONFIG_SPARSEMEM but without
CONFIG_SPARSEMEM_VMEMMAP.


-- 
Cheers,

David

  reply	other threads:[~2026-03-03  9:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-24  6:24 [PATCH V3 0/2] arm64/mm: Enable batched TLB flush in unmap_hotplug_range() Anshuman Khandual
2026-02-24  6:24 ` [PATCH V3 1/2] " Anshuman Khandual
2026-03-02 15:28   ` David Hildenbrand (Arm)
2026-03-03  5:55     ` Anshuman Khandual
2026-02-24  6:24 ` [PATCH V3 2/2] arm64/mm: Reject memory removal that splits a kernel leaf mapping Anshuman Khandual
2026-03-02 15:51   ` David Hildenbrand (Arm)
2026-03-03  4:01     ` Anshuman Khandual
2026-03-03  9:00       ` David Hildenbrand (Arm) [this message]
2026-03-04  8:53         ` Anshuman Khandual
2026-03-04  8:59           ` David Hildenbrand (Arm)
2026-03-02  7:34 ` [PATCH V3 0/2] arm64/mm: Enable batched TLB flush in unmap_hotplug_range() Anshuman Khandual

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=05e6034d-3493-4961-a97d-a80fff78289b@kernel.org \
    --to=david@kernel.org \
    --cc=anshuman.khandual@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=cl@gentwo.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=ryan.roberts@arm.com \
    --cc=will@kernel.org \
    --cc=yang@os.amperecomputing.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

all inboxes | Powered by JetHome®