public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Heiko Carstens <hca@linux.ibm.com>
To: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Kevin Brodsky <kevin.brodsky@arm.com>,
	David Hildenbrand <david@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Gerald Schaefer <gerald.schaefer@linux.ibm.com>,
	Christian Borntraeger <borntraeger@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Claudio Imbrenda <imbrenda@linux.ibm.com>,
	linux-s390@vger.kernel.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 5/6] s390/mm: Batch PTE updates in lazy MMU mode
Date: Mon, 27 Apr 2026 11:07:08 +0200	[thread overview]
Message-ID: <20260427090708.9079Cfc-hca@linux.ibm.com> (raw)
In-Reply-To: <104cde89-2a33-4b54-aa2a-86b58bd713d7-agordeev@linux.ibm.com>

On Fri, Apr 24, 2026 at 03:10:42PM +0200, Alexander Gordeev wrote:
> On Thu, Apr 23, 2026 at 02:28:24PM +0200, Heiko Carstens wrote:
> > > +static inline void set_pte(pte_t *ptep, pte_t pte)
> > > +{
> > > +	if (!ipte_batch_set_pte(ptep, pte))
> > > +		__set_pte(ptep, pte);
> > > +}
> > 
> > Not sure if you analyzed it, but it looks like this might be the reason why
> > you see the fork() slowdown: every page table operation now comes with a
> > function call, even if is not needed.
> > 
> > I guess it would be helpful to add an early exit to the ipte_batch() inlines.
> > E.g. going back to the example above:
> > 
> > static inline
> > bool ipte_batch_ptep_test_and_clear_young(struct vm_area_struct *vma,
> > 					  unsigned long addr, pte_t *ptep,
> > 					  int *res)
> > {
> > 	if (__is_defined(__DECOMPRESSOR))
> > 		return false;
> > --->	if (unlikely(!ipte_batch_active()))
> > --->		return false;
> > 	return __ipte_batch_ptep_test_and_clear_young(vma, addr, ptep, res);
> > }
> > 
> > Where ipte_batch_active() would be an inline function which simply tests a bit
> > in lowcore.
> 
> The bit check alone would not be enough - it should be done with the
> preemption disabled. Then it would be something like lazy_mmu_mode(),
> but with one or more values in the lowcore instead of percpu variable
> (at least ::base_pte to check whether ptep falls into the active range).

What I meant: you need a one bit check in the inlined function, so you can
decide if it is even necessary to do the function call. More checking could be
done. However all the overhead of function calls will go away with single bit
check.

Or in other words: enter_ipte_batch() should set a bit in lowcore which can be
easily tested. This bit _also_ indicates that preemption is disabled. So all
the extra preempt disable / enable pairs within the page table primitives are
not needed, after this bit is present und used.

> > Just a general comment about the naming conventions: imho ipte_batch is not a
> > nice choice, since the name of the facility is "ipte range". However I would
> > abstract even more, since nobody knows if there will be a different
> > instruction or facility to achieve all of this in a better way.
> > 
> > Anyway... maybe rename the file simply to mmu.c or tlb.c and change the
> > function prefixes accordingly so we end up with shorter function names?
> 
> I would in turn suggest lazy_mmu_ prefix and lazy_mmu.c source name
> to emphasize it implements the generic lazy mmu mode.

Ok.

> At the same time
> keep ipte_batch (or ipte_range rather) in the implementation itself.

That still doesn't look to good to me, but can be solved at a later time.

  reply	other threads:[~2026-04-27  9:07 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-15 15:01 [PATCH v2 0/6] s390/mm: Batch PTE updates in lazy MMU mode Alexander Gordeev
2026-04-15 15:01 ` [PATCH v2 1/6] mm: Make lazy MMU mode context-aware Alexander Gordeev
2026-04-20  8:45   ` Kevin Brodsky
2026-04-21  4:57     ` Alexander Gordeev
2026-04-21  8:40       ` Kevin Brodsky
2026-04-21 14:12         ` David Hildenbrand (Arm)
2026-04-21 14:15   ` David Hildenbrand (Arm)
2026-04-21 14:25     ` Alexander Gordeev
2026-04-23 10:49   ` Heiko Carstens
2026-04-15 15:01 ` [PATCH v2 2/6] mm/pgtable: Fix bogus comment to clear_not_present_full_ptes() Alexander Gordeev
2026-04-16  7:58   ` David Hildenbrand (Arm)
2026-04-16  8:53     ` Alexander Gordeev
2026-04-15 15:01 ` [PATCH v2 3/6] s390/mm: Complete ptep_get() conversion Alexander Gordeev
2026-04-23 10:51   ` Heiko Carstens
2026-04-24 11:54     ` Alexander Gordeev
2026-04-24 12:34       ` Heiko Carstens
2026-04-15 15:01 ` [PATCH v2 4/6] s390/mm: Make PTC and UV call order consistent Alexander Gordeev
2026-04-23 10:54   ` Heiko Carstens
2026-04-24 11:35     ` Alexander Gordeev
2026-04-15 15:01 ` [PATCH v2 5/6] s390/mm: Batch PTE updates in lazy MMU mode Alexander Gordeev
2026-04-16  5:40   ` Heiko Carstens
2026-04-16  5:51     ` Alexander Gordeev
2026-04-23 12:28   ` Heiko Carstens
2026-04-24 13:10     ` Alexander Gordeev
2026-04-27  9:07       ` Heiko Carstens [this message]
2026-04-15 15:01 ` [PATCH v2 6/6] s390/mm: Allow lazy MMU mode disabling Alexander Gordeev
2026-04-16  5:44   ` Heiko Carstens
2026-04-16  7:00     ` Alexander Gordeev
2026-04-16  8:22       ` Christian Borntraeger

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=20260427090708.9079Cfc-hca@linux.ibm.com \
    --to=hca@linux.ibm.com \
    --cc=agordeev@linux.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=borntraeger@linux.ibm.com \
    --cc=david@redhat.com \
    --cc=gerald.schaefer@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=kevin.brodsky@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-s390@vger.kernel.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