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=-13.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 77800C388F9 for ; Tue, 27 Oct 2020 09:07:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D454B206DC for ; Tue, 27 Oct 2020 09:07:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YaZ/ncPe" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D454B206DC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id EF6596B0062; Tue, 27 Oct 2020 05:07:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E7F016B006C; Tue, 27 Oct 2020 05:07:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CF7666B006E; Tue, 27 Oct 2020 05:07:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0103.hostedemail.com [216.40.44.103]) by kanga.kvack.org (Postfix) with ESMTP id 8E1146B0062 for ; Tue, 27 Oct 2020 05:07:38 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 1CE6C8249980 for ; Tue, 27 Oct 2020 09:07:38 +0000 (UTC) X-FDA: 77417127396.10.meat14_1a0ed742727a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id EE54616A0D2 for ; Tue, 27 Oct 2020 09:07:37 +0000 (UTC) X-HE-Tag: meat14_1a0ed742727a X-Filterd-Recvd-Size: 5252 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Tue, 27 Oct 2020 09:07:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603789656; 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=NfnTJiAmD6eL990WPNghr/NJ26oGL+XhgGB5yIi2I6Y=; b=YaZ/ncPewqk4KCP4W6BpGL6XAjH2lPnOsr5SDn7pA2dC+2p6IrSMLISLfzXeJ2VVMtfUV2 v9+bpv3xbKe+TNMYw5VxbnGR+j56pQGU0N58omCByMzzMDcE0WewOoefQ41883xMsZuotu wCUdvMVQJHqgSBLVvfW3uVbTqEFvhKs= 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-20-74QlMOsKMKCNEHE_ukwAEg-1; Tue, 27 Oct 2020 05:07:32 -0400 X-MC-Unique: 74QlMOsKMKCNEHE_ukwAEg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 234BD186842C; Tue, 27 Oct 2020 09:07:31 +0000 (UTC) Received: from [10.36.113.185] (ovpn-113-185.ams2.redhat.com [10.36.113.185]) by smtp.corp.redhat.com (Postfix) with ESMTP id A31C12C31E; Tue, 27 Oct 2020 09:07:29 +0000 (UTC) Subject: Re: [PATCH 2/3] mm, page_poison: use static key more efficiently To: Vlastimil Babka , 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-3-vbabka@suse.cz> From: David Hildenbrand Organization: Red Hat GmbH Message-ID: <4e35c52a-800a-4a60-2ef5-dd70a4f774c6@redhat.com> Date: Tue, 27 Oct 2020 10:07:28 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20201026173358.14704-3-vbabka@suse.cz> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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 26.10.20 18:33, Vlastimil Babka wrote: > Commit 11c9c7edae06 ("mm/page_poison.c: replace bool variable with static key") > changed page_poisoning_enabled() to a static key check. However, the function > is not inlined, so each check still involves a function call with overhead not > eliminated when page poisoning is disabled. > > Analogically to how debug_pagealloc is handled, this patch converts > page_poisoning_enabled() back to boolean check, and introduces > page_poisoning_enabled_static() for fast paths. Both functions are inlined. > > Also optimize the check that enables page poisoning instead of debug_pagealloc > for architectures without proper debug_pagealloc support. Move the check to > init_mem_debugging() to enable a single static key instead of having two > static branches in page_poisoning_enabled_static(). > > Signed-off-by: Vlastimil Babka [...] > +/* > + * For use in fast paths after init_mem_debugging() has run, or when a > + * false negative result is not harmful when called too early. > + */ > +static inline bool page_poisoning_enabled_static(void) > +{ > + return (static_branch_unlikely(&_page_poisoning_enabled)); return static_branch_unlikely(&_page_poisoning_enabled); > +} > #else > static inline bool page_poisoning_enabled(void) { return false; } > +static inline bool page_poisoning_enabled_static(void) { return false; } > static inline void kernel_poison_pages(struct page *page, int numpages, > int enable) { } > #endif > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index b168c58ef337..2a1be197649d 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -777,6 +777,17 @@ void init_mem_debugging() > } > } > > +#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())) Weird indentation if (page_poisoning_enabled() || (!IS_ENABLED(CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC) && debug_pagealloc_enabled())) > + static_branch_enable(&_page_poisoning_enabled); > +#endif > + > #ifdef CONFIG_DEBUG_PAGEALLOC > if (!debug_pagealloc_enabled()) > return; > @@ -2208,7 +2219,7 @@ static inline int check_new_page(struct page *page) > static inline bool free_pages_prezeroed(void) > { > return (IS_ENABLED(CONFIG_PAGE_POISONING_ZERO) && > - page_poisoning_enabled()) || want_init_on_free(); > + page_poisoning_enabled_static()) || want_init_on_free(); > } Apart from that LGTM. -- Thanks, David / dhildenb