Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp4566692ybe; Mon, 16 Sep 2019 14:35:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqzn19zyQNA4qDEtddxosTdSSQxf7RxIvqCOyX0JEDvZHaYzE9+74ttnnJG6sFxW5pFxcbMg X-Received: by 2002:aa7:d694:: with SMTP id d20mr1436402edr.226.1568669710188; Mon, 16 Sep 2019 14:35:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568669710; cv=none; d=google.com; s=arc-20160816; b=kTxqmsOrZjHsdt6vim3r4nKHZ8CBT0iOOzMel2zKa43aprsGRrwFlYFMfKERb5jI9Z 3u1bGOv6MSsrfk+XLqB8H5rzt9QCyZTBWoxiPz/Nryzb74Do2SlKoiZ12UqaWnqYlQML VlCmBd5EeHOVZ4m+ExZqm2XEgxGrS05N23jSTt3cwiHYCZZj2Q/yd+IcP/3CCAch1jnK 7H1/WzoG8LTL9aBKa8W2qHkPEp+saebfQx+cfQ1DQ6CV/pAxXa8UVb9WXKDOQJhBTQg3 smvXfBp4OJ3tTeX/GIQo7skevU0Vgq8gBcW6mtQYc7+IqzrgEwNBww0IyqqM80B8rYMh FEJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=yOrYKwpADy224jlRZ25gTWPwlOosLMaBNWto4Qr7Prs=; b=ydtvFMzCyd9qzWL60LjBUptSV3fN0G7gKESrDBF7pK4LIxnr8o6Rcw+tIsGfEmVv2G xjxaL1zBIJnHVOHuvIzN9w0g4DzzMQWrBRYJqk7ik3DcyJ/YZpr3LWop61W39bjU8xvP CsNpRqJg+ZAIEhX3zzZH9EH/svKLeLXAN9vmkt7NB9Rzhrbre7QK52/9lD3luG3vz2Sh 2ebxUdX6HywVA8TCdSTkMTQNkd6YhP3ju3jFQf6mNQXkhoo8ksCkRZeKmVXedQOwL50b 1Cljs0x8HCz/EbPtCswJOahNpUtIO3815DdDrR5cXERuB6nM8oLPKFWmvOERekqYj9/Y q9fw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id oa24si93524ejb.41.2019.09.16.14.34.47; Mon, 16 Sep 2019 14:35:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731606AbfIPP5n (ORCPT + 99 others); Mon, 16 Sep 2019 11:57:43 -0400 Received: from relay.sw.ru ([185.231.240.75]:49108 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730023AbfIPP5n (ORCPT ); Mon, 16 Sep 2019 11:57:43 -0400 Received: from [172.16.25.5] by relay.sw.ru with esmtp (Exim 4.92) (envelope-from ) id 1i9tNU-0003lm-Nv; Mon, 16 Sep 2019 18:57:24 +0300 Subject: Re: [PATCH v3] mm/kasan: dump alloc and free stack for page allocator To: Vlastimil Babka , Walter Wu Cc: Qian Cai , Alexander Potapenko , Dmitry Vyukov , Matthias Brugger , Andrew Morton , Martin Schwidefsky , Andrey Konovalov , Arnd Bergmann , linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, wsd_upstream@mediatek.com References: <20190911083921.4158-1-walter-zh.wu@mediatek.com> <5E358F4B-552C-4542-9655-E01C7B754F14@lca.pw> <1568297308.19040.5.camel@mtksdccf07> <613f9f23-c7f0-871f-fe13-930c35ef3105@suse.cz> <79fede05-735b-8477-c273-f34db93fd72b@virtuozzo.com> <6d58ce86-b2a4-40af-bf40-c604b457d086@suse.cz> From: Andrey Ryabinin Message-ID: <4e76e7ce-1d61-524a-622b-663c01d19707@virtuozzo.com> Date: Mon, 16 Sep 2019 18:57:23 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <6d58ce86-b2a4-40af-bf40-c604b457d086@suse.cz> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/16/19 12:42 PM, Vlastimil Babka wrote: > On 9/12/19 7:05 PM, Andrey Ryabinin wrote: >> >> Or another alternative option (and actually easier one to implement), leave PAGE_OWNER as is (no "select"s in Kconfigs) >> Make PAGE_OWNER_FREE_STACK like this: >> >> +config PAGE_OWNER_FREE_STACK >> + def_bool KASAN || DEBUG_PAGEALLOC >> + depends on PAGE_OWNER >> + >> >> So, users that want alloc/free stack will have to enable CONFIG_PAGE_OWNER=y and add page_owner=on to boot cmdline. >> >> >> Basically the difference between these alternative is whether we enable page_owner by default or not. But there is always a possibility to disable it. > > OK, how about this? > ... > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index c5d62f1c2851..d9e44671af3f 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -710,8 +710,12 @@ static int __init early_debug_pagealloc(char *buf) > if (kstrtobool(buf, &enable)) > return -EINVAL; > > - if (enable) > + if (enable) { > static_branch_enable(&_debug_pagealloc_enabled); > +#ifdef CONFIG_PAGE_OWNER > + page_owner_free_stack_disabled = false; I think this won't work with CONFIG_DEBUG_PAGEALLOC_ENABLE_DEFAULT=y > +#endif > + } > > return 0; > } > diff --git a/mm/page_owner.c b/mm/page_owner.c > index dee931184788..b589bfbc4795 100644 > --- a/mm/page_owner.c > +++ b/mm/page_owner.c > @@ -24,13 +24,15 @@ struct page_owner { > short last_migrate_reason; > gfp_t gfp_mask; > depot_stack_handle_t handle; > -#ifdef CONFIG_DEBUG_PAGEALLOC > +#ifdef CONFIG_PAGE_OWNER_FREE_STACK > depot_stack_handle_t free_handle; > #endif > }; > > static bool page_owner_disabled = true; > +bool page_owner_free_stack_disabled = true; > DEFINE_STATIC_KEY_FALSE(page_owner_inited); > +static DEFINE_STATIC_KEY_FALSE(page_owner_free_stack); > > static depot_stack_handle_t dummy_handle; > static depot_stack_handle_t failure_handle; > @@ -46,6 +48,9 @@ static int __init early_page_owner_param(char *buf) > if (strcmp(buf, "on") == 0) > page_owner_disabled = false; > > + if (!page_owner_disabled && IS_ENABLED(CONFIG_KASAN)) I'd rather keep all logic in one place, i.e. "if (!page_owner_disabled && (IS_ENABLED(CONFIG_KASAN) || debug_pagealloc_enabled())" With this no changes in early_debug_pagealloc() required and CONFIG_DEBUG_PAGEALLOC_ENABLE_DEFAULT=y should also work correctly. > + page_owner_free_stack_disabled = false; > + > return 0; > } > early_param("page_owner", early_page_owner_param);