Re: [PATCH v5 7/9] mm/mremap: Move TLB flush outside page table lock

2021-05-24 Thread Aneesh Kumar K.V
Linus Torvalds writes: > On Fri, May 21, 2021 at 3:04 AM Aneesh Kumar K.V > wrote: >> >> We could do MOVE_PMD with something like below? A equivalent MOVE_PUD >> will be costlier which makes me wonder whether we should even support that? > > Well, without USE_SPLIT_PTE_PTLOCKS the pud case would

Re: [PATCH v5 7/9] mm/mremap: Move TLB flush outside page table lock

2021-05-21 Thread Aneesh Kumar K.V
On 5/21/21 9:33 PM, Linus Torvalds wrote: On Fri, May 21, 2021 at 3:04 AM Aneesh Kumar K.V wrote: We could do MOVE_PMD with something like below? A equivalent MOVE_PUD will be costlier which makes me wonder whether we should even support that? Well, without USE_SPLIT_PTE_PTLOCKS the pud case

Re: [PATCH v5 7/9] mm/mremap: Move TLB flush outside page table lock

2021-05-21 Thread Linus Torvalds
On Fri, May 21, 2021 at 5:25 AM Liam Howlett wrote: > > mremap holds the mmap_sem in write mode as well, doesn't it? How is the user > thread > getting the new location? No amount of locking protects against the HW page table walker (or, indeed, software ones, but they are irrelevant). And an

Re: [PATCH v5 7/9] mm/mremap: Move TLB flush outside page table lock

2021-05-21 Thread Linus Torvalds
On Fri, May 21, 2021 at 3:04 AM Aneesh Kumar K.V wrote: > > We could do MOVE_PMD with something like below? A equivalent MOVE_PUD > will be costlier which makes me wonder whether we should even support that? Well, without USE_SPLIT_PTE_PTLOCKS the pud case would be trivial too. But everybody uses

Re: [PATCH v5 7/9] mm/mremap: Move TLB flush outside page table lock

2021-05-21 Thread Aneesh Kumar K.V
On 5/21/21 8:54 PM, Liam Howlett wrote: * Aneesh Kumar K.V [210521 08:51]: On 5/21/21 11:43 AM, Linus Torvalds wrote: On Thu, May 20, 2021 at 5:03 PM Aneesh Kumar K.V wrote: On 5/21/21 8:10 AM, Linus Torvalds wrote: So mremap does need to flush the TLB before releasing the page table lock

Re: [PATCH v5 7/9] mm/mremap: Move TLB flush outside page table lock

2021-05-21 Thread Liam Howlett
* Aneesh Kumar K.V [210521 08:51]: > On 5/21/21 11:43 AM, Linus Torvalds wrote: > > On Thu, May 20, 2021 at 5:03 PM Aneesh Kumar K.V > > wrote: > > > > > > On 5/21/21 8:10 AM, Linus Torvalds wrote: > > > > > > > > So mremap does need to flush the TLB before releasing the page table > > > > lock

Re: [PATCH v5 7/9] mm/mremap: Move TLB flush outside page table lock

2021-05-21 Thread Aneesh Kumar K.V
"Aneesh Kumar K.V" writes: > On 5/21/21 11:43 AM, Linus Torvalds wrote: >> On Thu, May 20, 2021 at 5:03 PM Aneesh Kumar K.V >> wrote: >>> >>> On 5/21/21 8:10 AM, Linus Torvalds wrote: So mremap does need to flush the TLB before releasing the page table lock, because that's the lif

Re: [PATCH v5 7/9] mm/mremap: Move TLB flush outside page table lock

2021-05-21 Thread Aneesh Kumar K.V
On 5/21/21 11:43 AM, Linus Torvalds wrote: On Thu, May 20, 2021 at 5:03 PM Aneesh Kumar K.V wrote: On 5/21/21 8:10 AM, Linus Torvalds wrote: So mremap does need to flush the TLB before releasing the page table lock, because that's the lifetime boundary for the page that got moved. How will

Re: [PATCH v5 7/9] mm/mremap: Move TLB flush outside page table lock

2021-05-20 Thread Linus Torvalds
On Thu, May 20, 2021 at 5:03 PM Aneesh Kumar K.V wrote: > > On 5/21/21 8:10 AM, Linus Torvalds wrote: > > > > So mremap does need to flush the TLB before releasing the page table > > lock, because that's the lifetime boundary for the page that got > > moved. > > How will we avoid that happening wi

Re: [PATCH v5 7/9] mm/mremap: Move TLB flush outside page table lock

2021-05-20 Thread Aneesh Kumar K.V
"Aneesh Kumar K.V" writes: > On 5/21/21 8:10 AM, Linus Torvalds wrote: >> On Thu, May 20, 2021 at 6:57 AM Aneesh Kumar K.V >> wrote: >>> >>> Wondering whether this is correct considering we are holding mmap_sem in >>> write mode in mremap. >> >> Right. So *normally* the rule is to EITHER >> >>

Re: [PATCH v5 7/9] mm/mremap: Move TLB flush outside page table lock

2021-05-20 Thread Aneesh Kumar K.V
On 5/21/21 8:10 AM, Linus Torvalds wrote: On Thu, May 20, 2021 at 6:57 AM Aneesh Kumar K.V wrote: Wondering whether this is correct considering we are holding mmap_sem in write mode in mremap. Right. So *normally* the rule is to EITHER - hold the mmap_sem for writing OR - hold the pag

Re: [PATCH v5 7/9] mm/mremap: Move TLB flush outside page table lock

2021-05-20 Thread Linus Torvalds
On Thu, May 20, 2021 at 6:57 AM Aneesh Kumar K.V wrote: > > Wondering whether this is correct considering we are holding mmap_sem in > write mode in mremap. Right. So *normally* the rule is to EITHER - hold the mmap_sem for writing OR - hold the page table lock and that the TLB flush needs

Re: [PATCH v5 7/9] mm/mremap: Move TLB flush outside page table lock

2021-05-20 Thread Aneesh Kumar K.V
On 5/20/21 8:56 PM, Aneesh Kumar K.V wrote: On 4/22/21 11:13 AM, Aneesh Kumar K.V wrote: Move TLB flush outside page table lock so that kernel does less with page table lock held. Releasing the ptl with old TLB contents still valid will behave such that such access happened before the level3 or

Re: [PATCH v5 7/9] mm/mremap: Move TLB flush outside page table lock

2021-05-20 Thread Aneesh Kumar K.V
On 4/22/21 11:13 AM, Aneesh Kumar K.V wrote: Move TLB flush outside page table lock so that kernel does less with page table lock held. Releasing the ptl with old TLB contents still valid will behave such that such access happened before the level3 or level2 entry update. Ok this break the pa