From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk0-f199.google.com (mail-qk0-f199.google.com [209.85.220.199]) by kanga.kvack.org (Postfix) with ESMTP id 954936B0003 for ; Wed, 23 May 2018 05:12:58 -0400 (EDT) Received: by mail-qk0-f199.google.com with SMTP id o97-v6so11093160qkh.14 for ; Wed, 23 May 2018 02:12:58 -0700 (PDT) Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0136.outbound.protection.outlook.com. [104.47.0.136]) by mx.google.com with ESMTPS id o35-v6si2773614qte.336.2018.05.23.02.12.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 May 2018 02:12:57 -0700 (PDT) Subject: Re: [PATCH v6 17/17] mm: Distinguish VMalloc pages References: <20180518194519.3820-1-willy@infradead.org> <20180518194519.3820-18-willy@infradead.org> <74e9bf39-ae17-cc00-8fca-c34b75675d49@virtuozzo.com> <20180522175836.GB1237@bombadil.infradead.org> <20180523063439.GD20441@dhcp22.suse.cz> From: Andrey Ryabinin Message-ID: Date: Wed, 23 May 2018 12:14:10 +0300 MIME-Version: 1.0 In-Reply-To: <20180523063439.GD20441@dhcp22.suse.cz> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Michal Hocko Cc: Matthew Wilcox , linux-mm@kvack.org, Matthew Wilcox , Andrew Morton , "Kirill A . Shutemov" , Christoph Lameter , Lai Jiangshan , Pekka Enberg , Vlastimil Babka , Dave Hansen , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= On 05/23/2018 09:34 AM, Michal Hocko wrote: > On Tue 22-05-18 22:57:34, Andrey Ryabinin wrote: >> >> >> On 05/22/2018 08:58 PM, Matthew Wilcox wrote: >>> On Tue, May 22, 2018 at 07:10:52PM +0300, Andrey Ryabinin wrote: >>>> On 05/18/2018 10:45 PM, Matthew Wilcox wrote: >>>>> From: Matthew Wilcox >>>>> >>>>> For diagnosing various performance and memory-leak problems, it is helpful >>>>> to be able to distinguish pages which are in use as VMalloc pages. >>>>> Unfortunately, we cannot use the page_type field in struct page, as >>>>> this is in use for mapcount by some drivers which map vmalloced pages >>>>> to userspace. >>>>> >>>>> Use a special page->mapping value to distinguish VMalloc pages from >>>>> other kinds of pages. Also record a pointer to the vm_struct and the >>>>> offset within the area in struct page to help reconstruct exactly what >>>>> this page is being used for. >>>> >>>> This seems useless. page->vm_area and page->vm_offset are never used. >>>> There are no follow up patches which use this new information 'For diagnosing various performance and memory-leak problems', >>>> and no explanation how is it can be used in current form. >>> >>> Right now, it's by-hand. tools/vm/page-types.c will tell you which pages >>> are allocated to VMalloc. Many people use kernel debuggers, crashdumps >>> and similar to examine the kernel's memory. Leaving these breadcrumbs >>> is helpful, and those fields simply weren't in use before. >>> >>>> Also, this patch breaks code like this: >>>> if (mapping = page_mapping(page)) >>>> // access mapping >>> >>> Example of broken code, please? Pages allocated from the page allocator >>> with alloc_page() come with page->mapping == NULL. This code snippet >>> would not have granted access to vmalloc pages before. >>> >> >> Some implementation of the flush_dcache_page(), also set_page_dirty() can be called >> on userspace-mapped vmalloc pages during unmap - zap_pte_range() -> set_page_dirty() > > Do you have any specific example? git grep -e remap_vmalloc_range -e vmalloc_user But that's not all, vmalloc*() + vmalloc_to_page() + vm_insert_page() are another candidates. > Why would anybody map vmalloc pages to the userspace? To have shared memory between usespace and the kernel. > flush_dcache_page on a vmalloc page sounds quite > unexpected to me as well. > remap_vmalloc_range()->vm_insret_page()->insert_page()->flush_dcache_page()