Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3447635pxf; Mon, 29 Mar 2021 02:26:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8mnmMU7ec8Wz8C+rj/tc2+jeG0yK0zy0PJDbECuYWtmYdG6XY9+YcU57B+Fz3Ke5zODao X-Received: by 2002:a17:906:2504:: with SMTP id i4mr27901055ejb.115.1617009969650; Mon, 29 Mar 2021 02:26:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617009969; cv=none; d=google.com; s=arc-20160816; b=BI4tpKADIi7WSMtTiiCN34RRSWVygi493fpNVpxx1FklJme++KbJXXFxRZhYtRQH3w WAbbzEcLz9UUCQ97ABD6XRZ3VsN4XNj5yl1MNBaf3XQIcC7/pJ+V84c4H9rN3l9bSksJ 34Zw+cU/z3C96CVUadKsCBe9Z4yFMXyFicr3cEtVomAZAdi7fmUKTqPGx8RaA0PSgsE4 zuq40nj4oyDoCh4Zg7iocHVtyK8ZoUTak+GOOD0zUNLORa03dxVh8x2syiOwFrJisVU/ yRSq/3wtmqgHjhkPcPiYjOzlnpWLrletWbWo5IMvnapQ3re+xyahnh681ciCyO7bsydf id7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:subject :organization:from:references:cc:to:dkim-signature; bh=sNdWxHwtlPTSLgjKBuoZy8VuUpSPf2A9bGzW9m7EMqs=; b=uNiTQDbDBnOcTNSb83UrUhdYywbny/LUD56Zycenewd20FAnEojoLq1EpLSO/t6rVe uHHj4u462csAdH/tM0sTeH3vV7Fcown+hPQ6HBV8bAWl3WabcSgtbTdwYFuxGMiSl7Xl JKlwfEzQ4rUylHF4UXxLRtck2afTd97G2FIBTy6Twz6zlaIAzcvv2q7dOGY3w9HZPYxB Q78Sj/TOn1mu7Yvv1pBO2zMwYGqWsPZBr8dCKQ6fIVD6N2vzUsnnO+PzCme3nHQUPb8A 8VIocxQpD3nTQF8PQLFRj5PYbq61k41hsH6rUyar7nJt5DjeoN8BCrAEq4gh2roKLFaS gqvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=B678AYHX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p10si12661141ejg.131.2021.03.29.02.25.47; Mon, 29 Mar 2021 02:26:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=B678AYHX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230319AbhC2JYW (ORCPT + 99 others); Mon, 29 Mar 2021 05:24:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49092 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231751AbhC2JXt (ORCPT ); Mon, 29 Mar 2021 05:23:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617009828; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sNdWxHwtlPTSLgjKBuoZy8VuUpSPf2A9bGzW9m7EMqs=; b=B678AYHXDNIsV+qvSc6kD6mzLvkel2O++FltgGBLhQX31mIqli/NwwKA/9ZgjsV5pf3QYD hg7eBnODMcCB8bQMY0zlwYNTS3IzRTTjm9XZAz8LK8bxpcn3Ay7Lh6iZYvZUhJEeELMs4g QAsQSsSxYqXAWKhmJ/O996ultG1JUjc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-213-3--sNhDeOqyirpC_2KIBtw-1; Mon, 29 Mar 2021 05:23:27 -0400 X-MC-Unique: 3--sNhDeOqyirpC_2KIBtw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 90B12801814; Mon, 29 Mar 2021 09:23:25 +0000 (UTC) Received: from [10.36.114.205] (ovpn-114-205.ams2.redhat.com [10.36.114.205]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2738F5D9F0; Mon, 29 Mar 2021 09:23:23 +0000 (UTC) To: Sergei Trofimovich , Vlastimil Babka , Andrew Morton , Andrey Konovalov Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20210327180348.137d8fe2@sf> <20210327182144.3213887-1-slyfox@gentoo.org> From: David Hildenbrand Organization: Red Hat GmbH Subject: Re: [PATCH v2] mm: page_alloc: ignore init_on_free=1 for debug_pagealloc=1 Message-ID: Date: Mon, 29 Mar 2021 11:23:23 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: <20210327182144.3213887-1-slyfox@gentoo.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27.03.21 19:21, Sergei Trofimovich wrote: > On !ARCH_SUPPORTS_DEBUG_PAGEALLOC (like ia64) debug_pagealloc=1 > implies page_poison=on: > > if (page_poisoning_enabled() || > (!IS_ENABLED(CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC) && > debug_pagealloc_enabled())) > static_branch_enable(&_page_poisoning_enabled); > > page_poison=on needs to init_on_free=1. > > Before the change id happened too late for the following case: > - have PAGE_POISONING=y > - have page_poison unset > - have !ARCH_SUPPORTS_DEBUG_PAGEALLOC arch (like ia64) > - have init_on_free=1 > - have debug_pagealloc=1 > > That way we get both keys enabled: > - static_branch_enable(&init_on_free); > - static_branch_enable(&_page_poisoning_enabled); > > which leads to poisoned pages returned for __GFP_ZERO pages. > > After the change we execute only: > - static_branch_enable(&_page_poisoning_enabled); > and ignore init_on_free=1. > > CC: Vlastimil Babka > CC: Andrew Morton > CC: linux-mm@kvack.org > CC: David Hildenbrand > CC: Andrey Konovalov > Link: https://lkml.org/lkml/2021/3/26/443 Again, Fixes: tag? IOW, which commit initially broke it. > Signed-off-by: Sergei Trofimovich > --- > mm/page_alloc.c | 30 +++++++++++++++++------------- > 1 file changed, 17 insertions(+), 13 deletions(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index d57d9b4f7089..10a8a1d28c11 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -764,32 +764,36 @@ static inline void clear_page_guard(struct zone *zone, struct page *page, > */ > void init_mem_debugging_and_hardening(void) > { > + bool page_poison_requested = page_poisoning_enabled(); s/page_poison_requested/page_poisoning_requested/ And I wonder if you should just initialize to "false" here. Without CONFIG_PAGE_POISONING, page_poisoning_enabled() will always return false, so it seems unnecessary. > + > +#ifdef CONFIG_PAGE_POISONING > + /* > + * Page poisoning is debug page alloc for some arches. If > + * either of those options are enabled, enable poisoning. > + */ > + if (page_poisoning_enabled() || > + (!IS_ENABLED(CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC) && > + debug_pagealloc_enabled())) { > + static_branch_enable(&_page_poisoning_enabled); > + page_poison_requested = true; > + } > +#endif Apart from that, looks good. -- Thanks, David / dhildenb