From patchwork Tue Oct 5 15:31:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 12537087 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4B66C433FE for ; Tue, 5 Oct 2021 15:31:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CF51C6115B for ; Tue, 5 Oct 2021 15:31:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CF51C6115B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 25000900002; Tue, 5 Oct 2021 11:31:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1FFFA6B0071; Tue, 5 Oct 2021 11:31:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0EF26900002; Tue, 5 Oct 2021 11:31:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0119.hostedemail.com [216.40.44.119]) by kanga.kvack.org (Postfix) with ESMTP id 01B626B006C for ; Tue, 5 Oct 2021 11:31:45 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id BAFB02BFAF for ; Tue, 5 Oct 2021 15:31:45 +0000 (UTC) X-FDA: 78662773770.01.2D317FD Received: from mail-il1-f181.google.com (mail-il1-f181.google.com [209.85.166.181]) by imf27.hostedemail.com (Postfix) with ESMTP id 3091A7008034 for ; Tue, 5 Oct 2021 15:31:45 +0000 (UTC) Received: by mail-il1-f181.google.com with SMTP id l20so9914311ilk.2 for ; Tue, 05 Oct 2021 08:31:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20210112.gappssmtp.com; s=20210112; h=to:from:subject:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=tVuQHObub2YNkMXj0VdNY1wP8i2BNR3veQbUik+SlKs=; b=tr0pADEUH6MVI60YI4iYvD82dol4p6zxiEPt9Uvw8Qn05LlXRqJhO59D0SIKDngSfw zmV8locsvef2a6+reUDFlrasoUwklCU52eE+O+MPVZF9kfAkhm4Ad4w52+kI+y6h67iV sG73suJbBtfeU/bhksIXMH7daeyuKOlSaV90+CUL+ux9/0eEbjiyQ0VfgUvRXAlCNgMB Zh9sW8jfYW9CkmVII+Nny1So2AakkStn7UaZI/rPd/qDlefxQEsoVqiV58eWws/yun3G lzJPZDyCMjVw38lcLlPxXFbKYHcSaDqJdN+lCWnjYHSuHrybjNglHaJ15IIIGNl2hvxo Ycfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=tVuQHObub2YNkMXj0VdNY1wP8i2BNR3veQbUik+SlKs=; b=3ZwzKDgCYwTsdXGy7oybkWXgNE6FmU5lsKwhHPVCQMTTUvO1mBhIBE+AlPba7o2ktp kgo/X9xjPOy5dTYQw38zy6SnCmzpupmZHLGSPkwER42tyD8uzoSLSDHrM60CRzcijIGY yjDVtTcrhmMaNy1Qx0hLYb+TLTx9EryB3QF2NrKgYQ/BxOhP7B2mEgcFE8i9NkEd2XDI roe7RedRAMNXutAQ/yX2kj6PLpOhChJ0cLOsGViah9VSxyRhBrH1T9MtMj6CQPUhwHZP DBZzZIz7V5XbiQqVHDC5Du6+/snZyrCJUv9qcVMVRcn1G9HkJX8VoiZCJiVlHHI7vlEe AwvA== X-Gm-Message-State: AOAM532JAbgG1SbZFyRHy/pD6pF++hTYVvjFjvyG+gEBQ88Lz4x4REln gu3Af5gPTeEDUVuXE32BS8zv6w== X-Google-Smtp-Source: ABdhPJzLni+rsnmQVPlhbLAVIyVjpQ14PZPb7Tizzee1xyL/Z3EPYMktlTDKiaprnhaEjLOh/4ItlA== X-Received: by 2002:a92:2902:: with SMTP id l2mr3149258ilg.276.1633447904257; Tue, 05 Oct 2021 08:31:44 -0700 (PDT) Received: from [192.168.1.30] ([207.135.234.126]) by smtp.gmail.com with ESMTPSA id v17sm10858206ilh.67.2021.10.05.08.31.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 05 Oct 2021 08:31:43 -0700 (PDT) To: LKML , Linux Memory Management List , Andrew Morton From: Jens Axboe Subject: [PATCH] mm: don't call should_failslab() for !CONFIG_FAILSLAB Message-ID: Date: Tue, 5 Oct 2021 09:31:43 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 Content-Language: en-US X-Rspamd-Queue-Id: 3091A7008034 X-Stat-Signature: bc7gq5erp1pgzqzwya7hykd9jfcgdhzy Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=kernel-dk.20210112.gappssmtp.com header.s=20210112 header.b=tr0pADEU; spf=pass (imf27.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.181 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none X-Rspamd-Server: rspam06 X-HE-Tag: 1633447905-456547 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000133, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Allocations can be a very hot path, and this out-of-line function call is noticeable. Signed-off-by: Jens Axboe 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