From patchwork Tue May 22 20:48:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 10419617 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DC27A6032C for ; Tue, 22 May 2018 20:48:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9F9029120 for ; Tue, 22 May 2018 20:48:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BDDE829122; Tue, 22 May 2018 20:48:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1DAA229120 for ; Tue, 22 May 2018 20:48:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C5CC36B0003; Tue, 22 May 2018 16:48:41 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C32F86B0005; Tue, 22 May 2018 16:48:41 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B23A06B0006; Tue, 22 May 2018 16:48:41 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f70.google.com (mail-pl0-f70.google.com [209.85.160.70]) by kanga.kvack.org (Postfix) with ESMTP id 6DED66B0003 for ; Tue, 22 May 2018 16:48:41 -0400 (EDT) Received: by mail-pl0-f70.google.com with SMTP id q16-v6so12844775pls.15 for ; Tue, 22 May 2018 13:48:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:date:from:to :cc:subject:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=SXTdu3r+Gr4LibaRUk10yuR4sBpft/ziRGyFrkLv9UE=; b=o3N1YTa+0by6DzW0287Ie70vF87zcT6ORbWcPme5Bhv3kwBLilezyonxuGgSJlCA4U Jv5zkGdgVHloai++bg7OLQoDN2SXdezCfDcg3jiyZNGC+Fuevje14T+JyUMaH+CA188A PgP0PpCJxwoJz9ZRaH5upr+OvfXWAeRe9A2kxDIia3zNmvwH8MzHaUXZ/MZjkREU2L3t Z/wHG8aC37QBAYkdoeU184gs8HB45DfT72rgwmcfV3u8UJGmWpIokD17Ln/qOnsWDJ4z QuGHJYQq6WzPL+gaprX29V+d5jL5pg+uqHPk3UJLTMjxxtQCG/PBm2kX9nkC9xaHiSMh FRYw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of akpm@linux-foundation.org designates 140.211.169.12 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-Gm-Message-State: ALKqPwdVm1oHskQ4A3oZo0PWxtwun0biBpW/UuOxcE4RyFzg3xyS921x NFAheXfsTV6rzXpD8/Gedtc9IF/pxhPqm6rCtscUoVFPsNCaDse0ItMbG0AxQuVLz+2Ca/I5BHa I4TEnq2F1KvJagxZJP5lmDEFMXfWlrqsOKszVmaYarinl09hebIFiRzs02GImMx/mfg== X-Received: by 2002:a62:1211:: with SMTP id a17-v6mr43464pfj.104.1527022120991; Tue, 22 May 2018 13:48:40 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoOmVJHgzgavA6J+1SrHXGBqyphxUl0GIxHLuDoe1GtGyp6B875VxLHgE9uTs/0+gBv2Qlg X-Received: by 2002:a62:1211:: with SMTP id a17-v6mr43433pfj.104.1527022120234; Tue, 22 May 2018 13:48:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527022120; cv=none; d=google.com; s=arc-20160816; b=Sof8tZL01iiJrxOAW73QiaWXag5VHcXHdLENQkcG6OHpS5zSsYu5jZjPhymCt4gGhx lObb5ZuAZmJzK42FxMa+9s4HMS0Mosp4enxk09649HGQLbcVePM8AG/LDub2r8MaCiU5 sKaKAWCGTMaXkFRaHqDPdW63CyAoLSRPBdQGV3ljj1/CAKsKgRtuTSpWWtCpv0KyKcr1 7UyZWJ1SnWXokVKC8/cQk07cl0iYfzrkP9DvTVfg5yxFRx5itDMbdqzkRH9Kp72vPPys Wm523y2hMl+zE7Czj0F6RnxiRPuYWAECJfAqJASPeviqAq+Ly6q/kYIuboYPQfILyk20 kxdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:arc-authentication-results; bh=SXTdu3r+Gr4LibaRUk10yuR4sBpft/ziRGyFrkLv9UE=; b=atf3R39ypEpJh6jJzH2nb52oZzod7XDyyBAjC7AwE+meC9ChW6nNzoOCWbMt1bywR1 veJoCuEY0raqMDC/PBt7+zOVjKwJOFGX+KRQmQ0RvSOk4ulYq/iv9K7gs1PpcJmcfnuY jqMOgZZ+wknQ+JPcqvZVxrrtOSWMmaX65XqxnKZFTiKrIEtOIbQkudYL+EIl7qdqX+1X h9ePs3lObdKoED3QEbDBFqt5c057ID775bcH3dQmuSfTeHVha3WGjgAWRS2RGMphtaVc KjoxhIAR0eVhRDa0KNttZGBciPlmIV9XT0I5pOtT5EsbcxuR9MLQrUUKCOaY6w0STTEd SleQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of akpm@linux-foundation.org designates 140.211.169.12 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org. [140.211.169.12]) by mx.google.com with ESMTPS id d15-v6si18233767pln.533.2018.05.22.13.48.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 May 2018 13:48:40 -0700 (PDT) Received-SPF: pass (google.com: domain of akpm@linux-foundation.org designates 140.211.169.12 as permitted sender) client-ip=140.211.169.12; Authentication-Results: mx.google.com; spf=pass (google.com: domain of akpm@linux-foundation.org designates 140.211.169.12 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org Received: from akpm3.svl.corp.google.com (unknown [104.133.9.71]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 6AA88FD7; Tue, 22 May 2018 20:48:39 +0000 (UTC) Date: Tue, 22 May 2018 13:48:38 -0700 From: Andrew Morton To: Matthew Wilcox Cc: Andrey Ryabinin , linux-mm@kvack.org, Matthew Wilcox , "Kirill A . Shutemov" , Christoph Lameter , Lai Jiangshan , Pekka Enberg , Vlastimil Babka , Dave Hansen , =?ISO-8859-1?Q?J=E9r=F4me?= Glisse Subject: Re: [PATCH v6 17/17] mm: Distinguish VMalloc pages Message-Id: <20180522134838.fe59b6e4a405fa9af9fc0487@linux-foundation.org> In-Reply-To: <20180522201958.GC1237@bombadil.infradead.org> 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> <20180522201958.GC1237@bombadil.infradead.org> X-Mailer: Sylpheed 3.6.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP On Tue, 22 May 2018 13:19:58 -0700 Matthew Wilcox wrote: > On Tue, May 22, 2018 at 10:57:34PM +0300, 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() > > Ah, good catch! I'm anticipating we'll have other special values for > page->mapping in the future. so how about this? > > (no changelog because I assume Andrew will add this as a -fix patch) I give the -fix patches a single-line summary in the final rollup. > diff --git a/mm/util.c b/mm/util.c > index 10ca6f1d5c75..be81c9052ef7 100644 > --- a/mm/util.c > +++ b/mm/util.c > @@ -561,6 +561,8 @@ struct address_space *page_mapping(struct page *page) > mapping = page->mapping; > if ((unsigned long)mapping & PAGE_MAPPING_ANON) > return NULL; > + if ((unsigned long)mapping < PAGE_SIZE) > + return NULL; > > return (void *)((unsigned long)mapping & ~PAGE_MAPPING_FLAGS); > } -ENOCOMMENT ;) It's a bit sad to put even more stuff into page_mapping() just for page_types diddling. Is this really justified? How many people will use it, and get significant benefit from it? --- a/mm/util.c~mm-distinguish-vmalloc-pages-fix-fix +++ a/mm/util.c @@ -512,6 +512,8 @@ struct address_space *page_mapping(struc mapping = page->mapping; if ((unsigned long)mapping & PAGE_MAPPING_ANON) return NULL; + + /* Don't trip over a vmalloc page's MAPPING_VMalloc cookie */ if ((unsigned long)mapping < PAGE_SIZE) return NULL;