From patchwork Tue Mar 22 01:47:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 12788015 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E246C4332F for ; Tue, 22 Mar 2022 01:54:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235169AbiCVB4F (ORCPT ); Mon, 21 Mar 2022 21:56:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235132AbiCVB4C (ORCPT ); Mon, 21 Mar 2022 21:56:02 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B12CD44A02 for ; Mon, 21 Mar 2022 18:54:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 551C0B81B2D for ; Tue, 22 Mar 2022 01:54:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BDFC3C340F2; Tue, 22 Mar 2022 01:54:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1647914074; bh=DrZNvoTWRqfjg6xxjhNfSiAQdezk+5CXJVWZ5lfbe1c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q9FGcM2h8saccDKPgPJuGcb+BTl5k0PjuhPEt0a9+s0chdhlmlBYiGLlIZnZ9Ga8y 8z570cfR4rljp45pMGbIY0qFYSBsUp5MCwdUxvrrU+bd/REt97wtgHCE6z+qUxbLnW ZXZ5HzEiOPw+s6rOCBrSdibJFeTlO2k72DZd1GXKGTiY4V3kty9nU/LHB8aCTmJWBZ 9C9QxehdnWggq/UyMBPi4Ca/88SyxmN3xO1+one1uX1EIwXAoky/UtUhbRPpf8fJzw qzRmq2O4mgWR61no/cFS0SpK3p+06Op1OFQhCovvxa4QsGRPsm43DXpN8NKZnXnv0q faoznvIjLbZxQ== From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Cc: Chuck Lever , Enrico Scholz Subject: [PATCH v2 2/9] NFS: Fix memory allocation in rpc_alloc_task() Date: Mon, 21 Mar 2022 21:47:39 -0400 Message-Id: <20220322014746.1052984-3-trondmy@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220322014746.1052984-2-trondmy@kernel.org> References: <20220322014746.1052984-1-trondmy@kernel.org> <20220322014746.1052984-2-trondmy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Trond Myklebust As for rpc_malloc(), we first try allocating from the slab, then fall back to a non-waiting allocation from the mempool. Signed-off-by: Trond Myklebust --- net/sunrpc/sched.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index d59a033820be..b258b87a3ec2 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c @@ -1108,10 +1108,14 @@ static void rpc_init_task(struct rpc_task *task, const struct rpc_task_setup *ta rpc_init_task_statistics(task); } -static struct rpc_task * -rpc_alloc_task(void) +static struct rpc_task *rpc_alloc_task(void) { - return (struct rpc_task *)mempool_alloc(rpc_task_mempool, GFP_KERNEL); + struct rpc_task *task; + + task = kmem_cache_alloc(rpc_task_slabp, rpc_task_gfp_mask()); + if (task) + return task; + return mempool_alloc(rpc_task_mempool, GFP_NOWAIT); } /*