From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80822C32792 for ; Mon, 30 Sep 2019 12:49:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 38F0B216F4 for ; Mon, 30 Sep 2019 12:49:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lca.pw header.i=@lca.pw header.b="c9rl2ouY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 38F0B216F4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lca.pw Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DFDD66B0005; Mon, 30 Sep 2019 08:49:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DAEF56B0006; Mon, 30 Sep 2019 08:49:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CC4356B0007; Mon, 30 Sep 2019 08:49:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0190.hostedemail.com [216.40.44.190]) by kanga.kvack.org (Postfix) with ESMTP id A9C696B0005 for ; Mon, 30 Sep 2019 08:49:51 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 5EEAE55F89 for ; Mon, 30 Sep 2019 12:49:51 +0000 (UTC) X-FDA: 75991568982.21.fold23_731412a673024 X-HE-Tag: fold23_731412a673024 X-Filterd-Recvd-Size: 6073 Received: from mail-qt1-f194.google.com (mail-qt1-f194.google.com [209.85.160.194]) by imf03.hostedemail.com (Postfix) with ESMTP for ; Mon, 30 Sep 2019 12:49:50 +0000 (UTC) Received: by mail-qt1-f194.google.com with SMTP id f7so16811730qtq.7 for ; Mon, 30 Sep 2019 05:49:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lca.pw; s=google; h=message-id:subject:from:to:cc:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=6K4t2QaanAjiyfaxIbACT2mjoEJYSRRvAaJqq+DnP1g=; b=c9rl2ouYw3vJgLERGSrEISkC9A+UUnX6Ofv3pCbqI9nmR7zvAB6flw3hQoCTlo0Wko aKs/+s38bsVMP0aLoRI7CbKkcVTeMwsX4QzE891hXgojixue3ygkbwDyoQLqq7fwTGqm 8jPh+RbyYmadBcSUnDauljg9YrRjq0IK2rcXcGlrkIAJAkIl2fsUVuUmYiqqFmj5NWoA ImIzVpmL3Op/kpZoDtVBUh//19yHDjh/WdQE74s6QUU/aytZXLoIFKTd2GsVZj9TRNF+ oCUPrMBDp12tlNOFgIVkEprEN4phihsulPK7G3eQVwEQFAdXIzRTLOTmG+WFi9STLtpk 6ICg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=6K4t2QaanAjiyfaxIbACT2mjoEJYSRRvAaJqq+DnP1g=; b=Cf0FGiA9uCBfTeaM7utmSEa9r9kOIMzhmToVP9OsBwElgEgusUsCAeORN9taTus8cU K5CAQq9lwM/KGGnvCn29X3vAv73UqWB/XA5HBCyqABKBXTb27y07R/TFO5+/hUOLNV1C 6fCGBPxxgLbJ9GSCUSmk26WEkEInba3lCsDtZ9ZWmmLE6rs42/H9epJDVRFQTiLnpRpm d0GdF7rGMcoRqSsBdqWhZBXVww0EIcfLbSoj0vsDREFjbSR0NCJN3AA6x0vjXoAVvvB/ A2aquZhzxhyE57CGWievB/159P6eFSxAx8UNWSeq+35lckrGIvGC1kBlxPZr5ZtcUCkb 5xcg== X-Gm-Message-State: APjAAAWngAbvjx6IuRXDzPAPAfCv5nfFbPMg7fYCLiWVeJP6BD8xuiHx mpePI7gnSP5f/3//GZKgMwL4eA== X-Google-Smtp-Source: APXvYqwe6tj3QoB3PHebpJKdfxVIK3o6VVGtOXmL0DJDcuzZS+0wTwEaSEnijNE5GeAZB0r39jqS1g== X-Received: by 2002:ac8:110a:: with SMTP id c10mr1071249qtj.259.1569847790073; Mon, 30 Sep 2019 05:49:50 -0700 (PDT) Received: from dhcp-41-57.bos.redhat.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id a134sm5923647qkc.95.2019.09.30.05.49.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Sep 2019 05:49:49 -0700 (PDT) Message-ID: <1569847787.5576.244.camel@lca.pw> Subject: Re: [PATCH v2 2/3] mm, page_owner: decouple freeing stack trace from debug_pagealloc From: Qian Cai To: Vlastimil Babka , Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, "Kirill A. Shutemov" , Matthew Wilcox , Mel Gorman , Michal Hocko , Dmitry Vyukov , Walter Wu , Andrey Ryabinin Date: Mon, 30 Sep 2019 08:49:47 -0400 In-Reply-To: <20190930122916.14969-3-vbabka@suse.cz> References: <20190930122916.14969-1-vbabka@suse.cz> <20190930122916.14969-3-vbabka@suse.cz> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.6 (3.22.6-10.el7) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit 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: On Mon, 2019-09-30 at 14:29 +0200, Vlastimil Babka wrote: > The commit 8974558f49a6 ("mm, page_owner, debug_pagealloc: save and dump > freeing stack trace") enhanced page_owner to also store freeing stack trace, > when debug_pagealloc is also enabled. KASAN would also like to do this [1] to > improve error reports to debug e.g. UAF issues. Kirill has suggested that the > freeing stack trace saving should be also possible to be enabled separately. > > This patch therefore introduces a new kernel parameter page_owner_free to > enable the functionality in addition to the existing page_owner parameter. > The free stack saving is thus enabled in these cases: > 1) booting with page_owner=on and debug_pagealloc=on > 2) booting a KASAN kernel with page_owner=on > 3) booting with page_owner=on and page_owner_free=on > > To minimize runtime CPU and memory overhead when not boot-time enabled, the > patch introduces a new static key and struct page_ext_operations. > > [1] https://bugzilla.kernel.org/show_bug.cgi?id=203967 > > Suggested-by: Dmitry Vyukov > Suggested-by: Walter Wu > Suggested-by: Andrey Ryabinin > Suggested-by: Kirill A. Shutemov > Signed-off-by: Vlastimil Babka > --- > .../admin-guide/kernel-parameters.txt | 8 ++ > Documentation/dev-tools/kasan.rst | 3 + > include/linux/page_owner.h | 1 + > mm/page_ext.c | 1 + > mm/page_owner.c | 90 +++++++++++++------ > 5 files changed, 78 insertions(+), 25 deletions(-) > > diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt > index 944e03e29f65..14dcb66e3457 100644 > --- a/Documentation/admin-guide/kernel-parameters.txt > +++ b/Documentation/admin-guide/kernel-parameters.txt > @@ -3237,6 +3237,14 @@ > we can turn it on. > on: enable the feature > > + page_owner_free= > + [KNL] When enabled together with page_owner, store also > + the stack of who frees a page, for error page dump > + purposes. This is also implicitly enabled by > + debug_pagealloc=on or KASAN, so only page_owner=on is > + sufficient in those cases. > + on: enable the feature > + If users are willing to set page_owner=on, what prevent them from enabling KASAN as well? That way, we don't need this additional parameter. I read that KASAN supposes to be semi-production use ready, so the overhead is relatively low. There is even a choice to have KASAN_SW_TAGS on arm64 to work better with small devices.