From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758381AbdJQJrw (ORCPT ); Tue, 17 Oct 2017 05:47:52 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:57882 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755391AbdJQJrv (ORCPT ); Tue, 17 Oct 2017 05:47:51 -0400 Subject: Re: [PATCH -mm] mm, pagemap: Fix soft dirty marking for PMD migration entry To: "Huang, Ying" , Andrew Morton References: <20171017081818.31795-1-ying.huang@intel.com> Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Michal Hocko , "Kirill A. Shutemov" , David Rientjes , Arnd Bergmann , Hugh Dickins , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Daniel Colascione , Zi Yan , Naoya Horiguchi From: Anshuman Khandual Date: Tue, 17 Oct 2017 15:17:38 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <20171017081818.31795-1-ying.huang@intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-TM-AS-MML: disable x-cbid: 17101709-0040-0000-0000-000003E392CE X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17101709-0041-0000-0000-000025E5DBDA Message-Id: <8fd6b1d8-6dc3-29a8-0377-e4323b74d6af@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-10-17_06:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1710170138 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/17/2017 01:48 PM, Huang, Ying wrote: > From: Huang Ying > > Now, when the page table is walked in the implementation of > /proc//pagemap, pmd_soft_dirty() is used for both the PMD huge > page map and the PMD migration entries. That is wrong, > pmd_swp_soft_dirty() should be used for the PMD migration entries > instead because the different page table entry flag is used. Yeah, different flags can be used on various archs to represent mapped a PMD and a migration PMD entry. Sounds good. > > Cc: Michal Hocko > Cc: "Kirill A. Shutemov" > Cc: David Rientjes > Cc: Arnd Bergmann > Cc: Hugh Dickins > Cc: "Jérôme Glisse" > Cc: Daniel Colascione > Cc: Zi Yan > Cc: Naoya Horiguchi > Signed-off-by: "Huang, Ying" > --- > fs/proc/task_mmu.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c > index 2593a0c609d7..01aad772f8db 100644 > --- a/fs/proc/task_mmu.c > +++ b/fs/proc/task_mmu.c > @@ -1311,13 +1311,15 @@ static int pagemap_pmd_range(pmd_t *pmdp, unsigned long addr, unsigned long end, > pmd_t pmd = *pmdp; > struct page *page = NULL; > > - if ((vma->vm_flags & VM_SOFTDIRTY) || pmd_soft_dirty(pmd)) > + if (vma->vm_flags & VM_SOFTDIRTY) > flags |= PM_SOFT_DIRTY; > > if (pmd_present(pmd)) { > page = pmd_page(pmd); > > flags |= PM_PRESENT; > + if (pmd_soft_dirty(pmd)) > + flags |= PM_SOFT_DIRTY; > if (pm->show_pfn) > frame = pmd_pfn(pmd) + > ((addr & ~PMD_MASK) >> PAGE_SHIFT); > @@ -1329,6 +1331,8 @@ static int pagemap_pmd_range(pmd_t *pmdp, unsigned long addr, unsigned long end, > frame = swp_type(entry) | > (swp_offset(entry) << MAX_SWAPFILES_SHIFT); > flags |= PM_SWAP; > + if (pmd_swp_soft_dirty(pmd)) > + flags |= PM_SOFT_DIRTY; Though I was initially skeptical about whether this will compile on POWER because of lack of a pmd_swp_soft_dirty() definition but it turns out we have a generic one to fallback on as we dont define ARCH_ENABLE_THP_MIGRATION yet. #ifdef CONFIG_HAVE_ARCH_SOFT_DIRTY #ifndef CONFIG_ARCH_ENABLE_THP_MIGRATION static inline pmd_t pmd_swp_mksoft_dirty(pmd_t pmd) { return pmd; } static inline int pmd_swp_soft_dirty(pmd_t pmd) { return 0; } static inline pmd_t pmd_swp_clear_soft_dirty(pmd_t pmd) { return pmd; } #endif