Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1771281pxb; Thu, 7 Oct 2021 14:59:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuPZ1zPMIb+QJwY92krzD2cAj6E7I4qiXSYpmiFCJUa9hCRGQPPUHy7Gy0TVG5VBszdYtf X-Received: by 2002:a17:907:9908:: with SMTP id ka8mr9307609ejc.164.1633643989593; Thu, 07 Oct 2021 14:59:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633643989; cv=none; d=google.com; s=arc-20160816; b=dpL8mjCyuvO6XEiV3E6Upx4aZggQARaLHaPRSbfhTZo3MIsoRvDTEoYIFbhPwhaJo1 vl1CkbMUTH0gUELF/CaoihfOexYa4C1qa07dYs5hPYCNkfJLvbjxalvIgHl9RY85B4WN jHghlMZXxedQM2JyZ58asZghLuFFp48ncQkRZEeDiLUgA9SO+c1bn+wGDKCgIWe/tppA dszUGjze2+z7HxDQS5whdXTKa85XBWUnlshsk22L+UmCZFUrKLQTVgY7a5dzB0l95X9D anKkjyzhJlCyUlZSeiVI+DRXbwm8wvhfsgjysizUfVoE/KIpuHL40XLPXhj/SKYz1ML4 6mFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject:cc :from:references:to:content-language:user-agent:mime-version:date :message-id:dkim-signature:dkim-signature; bh=6B1VO+DAyC0SNt7AIeINO89Y01c7kiMHh/J/8X3K/8g=; b=eMcRJjJYqvzqIYO0rM6i5ZJxEtQM/VrDxLC4NKvZiz3ZbC1rm92O6nOIyVa1QSGUgx AO5L9a8zuasecW/uIv9g/ktWZXgYpd8rPRTjdwqVY8Op5x7FrYe/YkqU/3eOefeWLg34 5dtxm4dU+72+K6P8Tsi0ohbmEEuA625y/YhaXI1U3VFNxFAE7ZJkmeapFVYhuO1YcM8C X7ifuP+nPgrcRn2wO7Yos9TEX7u7ZliucyaZfqYyic9DoDdMKQdw3/QNjBe9vdS2SkcS XP2EtxcMdmvIeNR6NZc5bS26vaRFJb9pnDFJ2Tvr5isepvWvBZisVL4Rgf+0gV64wER/ ts8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=EXhzSbJp; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t17si1050320edd.346.2021.10.07.14.59.23; Thu, 07 Oct 2021 14:59:49 -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=@suse.cz header.s=susede2_rsa header.b=EXhzSbJp; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241214AbhJGPes (ORCPT + 99 others); Thu, 7 Oct 2021 11:34:48 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:45496 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230060AbhJGPer (ORCPT ); Thu, 7 Oct 2021 11:34:47 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id BC7041FE5D; Thu, 7 Oct 2021 15:32:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1633620772; h=from:from:reply-to: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=6B1VO+DAyC0SNt7AIeINO89Y01c7kiMHh/J/8X3K/8g=; b=EXhzSbJpJrTL4FOchfh0da/gwXR8mST5Kuv4U4Dcy2y8v/Kl/NmPDMULfluACAgJJDrUNi UQMcPzGHj0mO/Oxmf1Hhlqoapd/7B4fXamGoz8Lbub2iqL/QRMOA7hgv4eiA004ixW8OtG 2uWAj8PQCugzThuNpVRPSW8k+l2ynzA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1633620772; h=from:from:reply-to: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=6B1VO+DAyC0SNt7AIeINO89Y01c7kiMHh/J/8X3K/8g=; b=CyQ4yNgz1MUmR/R2AHC0yG55AEMOZGP7q7SuSqu3LZehv81fVnKbHDSeHwUWmOWzsUiKVO RDZRXIxEknKNJLDQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 7AEBD13EB7; Thu, 7 Oct 2021 15:32:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id c+BDHSQTX2FVfwAAMHmgww (envelope-from ); Thu, 07 Oct 2021 15:32:52 +0000 Message-ID: <2dfc6273-6cdd-f4f5-bed9-400873ac9152@suse.cz> Date: Thu, 7 Oct 2021 17:32:52 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.2 Content-Language: en-US To: Jens Axboe , LKML , Linux Memory Management List , Andrew Morton , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Jesper Dangaard Brouer , Christoph Lameter , David Rientjes , Pekka Enberg , Joonsoo Kim , Yonghong Song , John Fastabend , KP Singh , Howard McLauchlan References: From: Vlastimil Babka Cc: bpf@vger.kernel.org Subject: Re: [PATCH] mm: don't call should_failslab() for !CONFIG_FAILSLAB In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/5/21 17:31, Jens Axboe wrote: > Allocations can be a very hot path, and this out-of-line function > call is noticeable. > > Signed-off-by: Jens Axboe It used to be inline b4 (hi, Konstantin!) and then was converted to be like this intentionally :/ See 4f6923fbb352 ("mm: make should_failslab always available for fault injection") And now also kernel/bpf/verifier.c contains: BTF_ID(func, should_failslab) I think either your or Andrew's version will break this BTF_ID thing, at the very least. But I do strongly agree that putting unconditionally a non-inline call into slab allocator fastpath sucks. Can we make it so that bpf can only do these overrides when CONFIG_FAILSLAB is enabled? I don't know, perhaps putting this BTF_ID() in #ifdef as well, or providing a dummy that is always available (so that nothing breaks), but doesn't actually affect slab_pre_alloc_hook() unless CONFIG_FAILSLAB has been enabled? > --- > > diff --git a/include/linux/fault-inject.h b/include/linux/fault-inject.h > index e525f6957c49..3128d2c8b3b4 100644 > --- a/include/linux/fault-inject.h > +++ b/include/linux/fault-inject.h > @@ -64,8 +64,8 @@ static inline struct dentry *fault_create_debugfs_attr(const char *name, > > struct kmem_cache; > > -int should_failslab(struct kmem_cache *s, gfp_t gfpflags); > #ifdef CONFIG_FAILSLAB > +int should_failslab(struct kmem_cache *s, gfp_t gfpflags); > extern bool __should_failslab(struct kmem_cache *s, gfp_t gfpflags); > #else > static inline bool __should_failslab(struct kmem_cache *s, gfp_t gfpflags) > diff --git a/mm/slab.h b/mm/slab.h > index 58c01a34e5b8..92fd6fe01877 100644 > --- a/mm/slab.h > +++ b/mm/slab.h > @@ -491,8 +491,10 @@ static inline struct kmem_cache *slab_pre_alloc_hook(struct kmem_cache *s, > > might_alloc(flags); > > +#ifdef CONFIG_FAILSLAB > if (should_failslab(s, flags)) > return NULL; > +#endif > > if (!memcg_slab_pre_alloc_hook(s, objcgp, size, flags)) > return NULL; > diff --git a/mm/slab_common.c b/mm/slab_common.c > index ec2bb0beed75..c21bd447f237 100644 > --- a/mm/slab_common.c > +++ b/mm/slab_common.c > @@ -1323,6 +1323,7 @@ EXPORT_TRACEPOINT_SYMBOL(kmem_cache_alloc_node); > EXPORT_TRACEPOINT_SYMBOL(kfree); > EXPORT_TRACEPOINT_SYMBOL(kmem_cache_free); > > +#ifdef CONFIG_FAILSLAB > int should_failslab(struct kmem_cache *s, gfp_t gfpflags) > { > if (__should_failslab(s, gfpflags)) > @@ -1330,3 +1331,4 @@ int should_failslab(struct kmem_cache *s, gfp_t gfpflags) > return 0; > } > ALLOW_ERROR_INJECTION(should_failslab, ERRNO); > +#endif >