Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp4966423pxb; Tue, 5 Oct 2021 14:25:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwV6AzJlw/e2hpDdqdjOzObhpfdvgzguWWAcYuNa9VNpwXzmy/UhNFisSDlIh0L9y09u0H9 X-Received: by 2002:a17:906:c014:: with SMTP id e20mr27884531ejz.166.1633469112450; Tue, 05 Oct 2021 14:25:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633469112; cv=none; d=google.com; s=arc-20160816; b=AT5RwwU2KVXlM7Wnftytb5/17ZL3KKA/lIRFUB+FdHlIsxDXGjP509wYobP9/UyQ8I OpcLYd3sHjFQQweDKLlDAOTyINsswLivAbvzQutdp14ttpajjMREmWL9YkuWfED4i5PM XUtKu8ICX0n55v1FD1kT53hS+v16sUFM69CWBBs7IuSsbA7fyoKNueltlYz5Lxtqm6jJ bwl4z46nDacGPn1CZ9WgI50o3cdVh1lfukhaiNrhpKB9YosvDmeF5zKitgBbpDI9x0XV WH00Lv0x9Mi8tsT9Q0ht+cY/aPPPeE5f3at7J0psQ0tJeEAIZ+wrcCCStldypRLyqRFd d5bQ== 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:from:references :cc:to:subject:dkim-signature; bh=kC50MuF3+X16QbRLByewBMz1E35GzjVs9lAfPxIXfYY=; b=J1tWB2Qs3l100nY5XeUqwfN0UwDZPRqyo9vUgN+lS29X31MCKlTJcG6QrwjKzlODf8 DUrzqzuhnUJ9PrbO5Hp6yU57uyphHFJELIk95CoCXm7s8qCzHa8eMMSUreuWxv1OMZf5 ghbQ9jzBFuMDRKXyWvRg+MKA1B8TEZ24+PPaKutwYqkm0MWhzX+5r/4KaRjf/4JQL/+k qRMiyXhS2ZlJEr6iL5Q6V9QjGLiiOQEFc+AoUzH8XkS8Wv2H6/OALLeGyxpjcD/LQ2NC Nurh1Bg/3N4RHOx6ML6C4GPV8AAFBN10GSKZOLIvEHSqZzWdUPkzLDH9JvJJ7h0bMppQ WpFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20210112.gappssmtp.com header.s=20210112 header.b=5gAjizCN; 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 bl3si22958925ejb.204.2021.10.05.14.24.47; Tue, 05 Oct 2021 14:25:12 -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=@kernel-dk.20210112.gappssmtp.com header.s=20210112 header.b=5gAjizCN; 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 S236259AbhJEVWP (ORCPT + 99 others); Tue, 5 Oct 2021 17:22:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235679AbhJEVWM (ORCPT ); Tue, 5 Oct 2021 17:22:12 -0400 Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90E3BC061749 for ; Tue, 5 Oct 2021 14:20:21 -0700 (PDT) Received: by mail-il1-x131.google.com with SMTP id l20so807774ilk.2 for ; Tue, 05 Oct 2021 14:20:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20210112.gappssmtp.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=kC50MuF3+X16QbRLByewBMz1E35GzjVs9lAfPxIXfYY=; b=5gAjizCN0+xg1wqdFirBr2akZtrNHJBUUYuXonWwu9LHMnEb1Nx34amz+UXEg/QmeZ u+GmFPDT1tknv1UW4nSxIV7k+sXHKr0cOSpNFaHexwzAnHmncsm98gIRigvW3BIUc2Ev rnYo8tn/3F9k0pg3zFai44OOv2zKR45ocJEPF5tLwmPiHjQXfD0DJ35g3jnV46QS8Sl0 p4aWHW6fTiUl0Poh5fpkDCq5yx10Vsf+4tCAbwBpZyJTiuw7ik+VQmZFy1e+GKJCZA7u 4sVeIDRAvP4t32aL+FvA5NBftnDwJyoPm5DRCM24eOpTOFLsORRdsMpgFtZ+DFF1lXmD wj+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=kC50MuF3+X16QbRLByewBMz1E35GzjVs9lAfPxIXfYY=; b=R2UG5ALsEwNhAlWbgGTdKZB1hy5gJlKqApTgDd8vhaCMihMBjVw0CoWn8AD40VyYbB lTDZj/eKGencPHts00xWBO5aM2R4Mn+oFuC8aMDBE5Hjm0/huzzgfAxHloKwMJ+Bc4i7 AZbCIrwCRQgzk/UQHZ+Ya4CpaCreRzmb9vAgnb3gJ5Dcqmw4P8G5pKEmpnk6Mr8aqqzD //gtQcm0/d6FZR2uBSXoKhcnoOucnHB1kX1+yQZWegqHiFaqEDkRfaKCNAKM7fOaBv/G c9c6zJHWF1wSAt4udI29G1XtuRu/HZWxjPET9TotXRrPCFoHTyco+gFnQ0gXfc7nifCm RYnA== X-Gm-Message-State: AOAM532WHXlRiFBdB8zoWh3t8pavuSv6zWbnOFIwYxAVTA8ATIJbr2ZS 2txMpETpy4zJYhpvMlQx5JUVj5/euERf+Q== X-Received: by 2002:a92:c012:: with SMTP id q18mr4614971ild.84.1633468820840; Tue, 05 Oct 2021 14:20:20 -0700 (PDT) Received: from [192.168.1.116] ([66.219.217.159]) by smtp.gmail.com with ESMTPSA id b11sm6006843ile.12.2021.10.05.14.20.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 05 Oct 2021 14:20:20 -0700 (PDT) Subject: Re: [PATCH] mm: don't call should_failslab() for !CONFIG_FAILSLAB To: Andrew Morton Cc: LKML , Linux Memory Management List References: <20211005141832.d6f3d4e06c4ad7a06cd554dd@linux-foundation.org> From: Jens Axboe Message-ID: <316ad54a-67e9-879d-c406-6a4a606924aa@kernel.dk> Date: Tue, 5 Oct 2021 15:20:18 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20211005141832.d6f3d4e06c4ad7a06cd554dd@linux-foundation.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/5/21 3:18 PM, Andrew Morton wrote: > On Tue, 5 Oct 2021 09:31:43 -0600 Jens Axboe wrote: > >> Allocations can be a very hot path, and this out-of-line function >> call is noticeable. >> >> --- 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 > > Can we avoid the ifdefs here? > >> >> 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 > > Like, > > --- a/include/linux/fault-inject.h~mm-dont-call-should_failslab-for-config_failslab-fix > +++ a/include/linux/fault-inject.h > @@ -68,6 +68,10 @@ struct kmem_cache; > int should_failslab(struct kmem_cache *s, gfp_t gfpflags); > extern bool __should_failslab(struct kmem_cache *s, gfp_t gfpflags); > #else > +static inline int should_failslab(struct kmem_cache *s, gfp_t gfpflags) > +{ > + return 0; > +} > static inline bool __should_failslab(struct kmem_cache *s, gfp_t gfpflags) > { > return false; > --- a/mm/slab.h~mm-dont-call-should_failslab-for-config_failslab-fix > +++ a/mm/slab.h > @@ -491,10 +491,8 @@ static inline struct kmem_cache *slab_pr > > 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; > _ Yep, that'll work! -- Jens Axboe