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=-7.4 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 24E17C4363A for ; Tue, 27 Oct 2020 09:58:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5D3D32225C for ; Tue, 27 Oct 2020 09:58:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5D3D32225C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8F3216B006C; Tue, 27 Oct 2020 05:58:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8A2C56B006E; Tue, 27 Oct 2020 05:58:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 792066B0070; Tue, 27 Oct 2020 05:58:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0033.hostedemail.com [216.40.44.33]) by kanga.kvack.org (Postfix) with ESMTP id 494EE6B006C for ; Tue, 27 Oct 2020 05:58:19 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id CBC13180AD802 for ; Tue, 27 Oct 2020 09:58:18 +0000 (UTC) X-FDA: 77417255076.17.dress75_49085ec2727b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id AE508180D0181 for ; Tue, 27 Oct 2020 09:58:18 +0000 (UTC) X-HE-Tag: dress75_49085ec2727b X-Filterd-Recvd-Size: 3409 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf50.hostedemail.com (Postfix) with ESMTP for ; Tue, 27 Oct 2020 09:58:18 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 03F31B2BE; Tue, 27 Oct 2020 09:58:17 +0000 (UTC) Subject: Re: [PATCH 1/3] mm, page_alloc: do not rely on the order of page_poison and init_on_alloc/free parameters To: David Hildenbrand , Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Alexander Potapenko , Kees Cook , Michal Hocko , Mateusz Nosek References: <20201026173358.14704-1-vbabka@suse.cz> <20201026173358.14704-2-vbabka@suse.cz> <3784dac7-49cb-006b-7b9d-1244d5c59935@redhat.com> From: Vlastimil Babka Message-ID: <9a2b88de-3c01-21d0-69ff-08643f7c4b68@suse.cz> Date: Tue, 27 Oct 2020 10:58:16 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.3 MIME-Version: 1.0 In-Reply-To: <3784dac7-49cb-006b-7b9d-1244d5c59935@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US 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 10/27/20 10:03 AM, David Hildenbrand wrote: > On 26.10.20 18:33, Vlastimil Babka wrote: >> Enabling page_poison=1 together with init_on_alloc=1 or init_on_free=1 produces >> a warning in dmesg that page_poison takes precendence. However, as these >> warnings are printed in early_param handlers for init_on_alloc/free, they are >> not printed if page_poison is enabled later on the command line (handlers are >> called in the order of their parameters), or when init_on_alloc/free is always >> enabled by the respective config option - before the page_poison early param >> handler is called, it is not considered to be enabled. This is inconsistent. >> >> We can remove the dependency on order by making the init_on_* parameters only >> set a boolean variable, and postponing the evaluation after all early params >> have been processed. Introduce a new init_mem_debugging() function for that, >> and move the related debug_pagealloc processing there as well. > > init_mem_debugging() is somewhat sub-optimal - init_on_alloc=1 or > init_on_free=1 are rather security hardening mechanisms. Well yeah, init_mem_debugging_and_hardening()? > ... I wondered if this could be the place to initialize any kind of mm > parameters in the future. Like init_mem_params() or so. Maybe. In practice you often find out that different things have to be hooked in different points of the init process, and a single function might not be enough. I tried to group stuff that's really inter-related and can be initialized at the same time. >> >> As a result init_mem_debugging() knows always accurately if init_on_* and/or >> page_poison options were enabled. Thus we can also optimize want_init_on_alloc() >> and want_init_on_free(). We don't need to check page_poisoning_enabled() there, >> we can instead not enable the init_on_* tracepoint at all, if page poisoning is >> enabled. This results in a simpler and more effective code. > > LGTM > > Reviewed-by: David Hildenbrand Thanks!