Skip to contentSkip to conversation

s390/mm: use ipte range to invalidate multiple page table entries

PATCH Hillf Danton 2 participants 6 messages Jul 6, 2016 1 message not in the archive Memory management

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

Review

Quoted 13 lines
(quoted diff) +12 -0
+void ptep_invalidate_range(struct mm_struct *mm, unsigned long start,
+			   unsigned long end, pte_t *ptep)
+{
+	unsigned long nr;
+
+	if (!MACHINE_HAS_IPTE_RANGE || mm_has_pgste(mm))
+		return;
+	preempt_disable();
+	nr = (end - start) >> PAGE_SHIFT;
+	/* If the flush is likely to be local skip the ipte range */
+	if (nr && !cpumask_equal(mm_cpumask(mm),
+				 cpumask_of(smp_processor_id())))

s/smp/raw_smp/ to avoid adding schedule entry with page table lock held?

Review

Quoted 5 lines
(quoted diff) +5 -0
+		__ptep_ipte_range(start, nr - 1, ptep);
+	preempt_enable();
+}
+EXPORT_SYMBOL(ptep_invalidate_range);
+

thanks
Hillf

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#2 lore raw
Quoted 16 lines · On Wed, 06 Jul 2016 12:03:28 +0800 "Hillf Danton" <[email protected]>…

Review

Quoted 13 lines
(quoted diff) +12 -0
+void ptep_invalidate_range(struct mm_struct *mm, unsigned long start,
+			   unsigned long end, pte_t *ptep)
+{
+	unsigned long nr;
+
+	if (!MACHINE_HAS_IPTE_RANGE || mm_has_pgste(mm))
+		return;
+	preempt_disable();
+	nr = (end - start) >> PAGE_SHIFT;
+	/* If the flush is likely to be local skip the ipte range */
+	if (nr && !cpumask_equal(mm_cpumask(mm),
+				 cpumask_of(smp_processor_id())))

s/smp/raw_smp/ to avoid adding schedule entry with page table lock held?

There can not be a schedule entry with either the page table lock held or the preempt_disable() a few lines above.

Quoted 9 lines

Review

Quoted 5 lines
(quoted diff) +5 -0
+		__ptep_ipte_range(start, nr - 1, ptep);
+	preempt_enable();
+}
+EXPORT_SYMBOL(ptep_invalidate_range);
+

thanks
Hillf

Signature · 10 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#3 lore raw
Quoted 17 lines
Quoted 16 lines

Review

Quoted 13 lines
(quoted diff) +12 -0
+void ptep_invalidate_range(struct mm_struct *mm, unsigned long start,
+			   unsigned long end, pte_t *ptep)
+{
+	unsigned long nr;
+
+	if (!MACHINE_HAS_IPTE_RANGE || mm_has_pgste(mm))
+		return;
+	preempt_disable();
+	nr = (end - start) >> PAGE_SHIFT;
+	/* If the flush is likely to be local skip the ipte range */
+	if (nr && !cpumask_equal(mm_cpumask(mm),
+				 cpumask_of(smp_processor_id())))

s/smp/raw_smp/ to avoid adding schedule entry with page table lock held?

Quoted 3 lines

There can not be a schedule entry with either the page table lock held or the preempt_disable() a few lines above.

Yes, Sir.

Quoted 2 lines
Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+		__ptep_ipte_range(start, nr - 1, ptep);
+	preempt_enable();

Then would you please, Sir, take a look at another case where preempt is enabled?

Quoted 4 lines
Quoted 4 lines

Review

Quoted 3 lines
(quoted diff) +3 -0
+}
+EXPORT_SYMBOL(ptep_invalidate_range);
+

thanks
Hillf

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#4 lore raw
Quoted 20 lines · On Wed, 06 Jul 2016 14:42:16 +0800 "Hillf Danton" <[email protected]>…
Quoted 17 lines
Quoted 16 lines

Review

Quoted 13 lines
(quoted diff) +12 -0
+void ptep_invalidate_range(struct mm_struct *mm, unsigned long start,
+			   unsigned long end, pte_t *ptep)
+{
+	unsigned long nr;
+
+	if (!MACHINE_HAS_IPTE_RANGE || mm_has_pgste(mm))
+		return;
+	preempt_disable();
+	nr = (end - start) >> PAGE_SHIFT;
+	/* If the flush is likely to be local skip the ipte range */
+	if (nr && !cpumask_equal(mm_cpumask(mm),
+				 cpumask_of(smp_processor_id())))

s/smp/raw_smp/ to avoid adding schedule entry with page table lock held?

Quoted 3 lines

There can not be a schedule entry with either the page table lock held or the preempt_disable() a few lines above.

Quoted 7 lines

Yes, Sir.

Quoted 2 lines
Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+		__ptep_ipte_range(start, nr - 1, ptep);
+	preempt_enable();

Then would you please, Sir, take a look at another case where preempt is enabled?

You are still a bit cryptic, are you trying to tell me that your hint is about trying to avoid the preempt_enable() call?

The reason why I added the preempt_disable()/preempt_enable() pair to ptep_invalidate_range is that I recently got bitten by a preempt problem in the ptep_xchg_lazy() function which is used for ptep_get_and_clear(). Now ptep_get_and_clear() is used in vunmap_pte_range() which is called while preemption is allowed.

To keep things symmetrical it seems sensible to explicitely disable preemption on all ptep_xxx code paths with cpu mask checks, no?

Signature · 10 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#5 lore raw
Quoted 3 lines

You are still a bit cryptic,

Sorry, Sir, simply because I'm not native English speaker.

Quoted 3 lines

are you trying to tell me that your hint is
about trying to avoid the preempt_enable() call?

Yes, since we are already in the context with page table lock held.

thanks
Hillf

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#6 lore raw
Quoted 9 lines · On Wed, 06 Jul 2016 17:26:08 +0800 "Hillf Danton" <[email protected]>…
Quoted 3 lines

You are still a bit cryptic,

Sorry, Sir, simply because I'm not native English speaker.

Quoted 3 lines

are you trying to tell me that your hint is
about trying to avoid the preempt_enable() call?

Yes, since we are already in the context with page table lock held.

Ok, got it. An option would be to drop the preempt_disable/preempt_enable, add "BUG_ON(preemptible())" and use raw_smp_processor_id. But I wonder if it is worth the effort.

Signature · 10 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>