Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2405233pxp; Mon, 21 Mar 2022 19:21:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxG+oIrzzi8bV1MC+0OjUc4SUI/Nu8fKGIKSU8dJ8fnO5xmUwiIa0jnhRFlNC6Ozn70dXtG X-Received: by 2002:a17:902:dac7:b0:154:4899:85db with SMTP id q7-20020a170902dac700b00154489985dbmr10760030plx.9.1647915702876; Mon, 21 Mar 2022 19:21:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647915702; cv=none; d=google.com; s=arc-20160816; b=WPhp0CserFvUisIre+2adDPNxM9kB4cr7Zf8h4ij5fm9sti73RNQvj0frGiFqsFAKX YMpiwiU7gKIttjzcPAm584C1T+1iby6ETNwQ1tPvkN/unWLk+iP8Vtfl0I5KilUU2p1+ 6myHvVUxeAByznZeVfPbz9JOTtGoU3xqJxAIfoSTLfyzN1xMrXW7tLUuhGBP//h8o5Pq IzfvuGrrmkuLD8xrnXlW1sAN8eb0oHPDDCKPpL84kcRF738OhSXUSuvc0YIqEUDgTU6C BG/C1Qh8nGp900cyRO3qoxP8nDagW/kP/6iR+bVJVms7NSxiSPhKAt/SEIOnlCOmPaOz 0WFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Xri0yyU7qS4ikqETqtddbcMNpUj9go9pZemm+si0G5k=; b=mNFufCunrKSO4ORxCYKjS3xlL3kZENRjLh028TLfSLEf/UUdVWM9kqAOrSlJddDSYM QW0Nu5OHxtZABiEjQVU/9zVgT8GDjJ2Uzxl8EbQ6Xp9NND1a8W3lWNZWcQVus06v76Nx auDjD1Lj3WlJ3OvNNMURb3uMCReV48aGSZrscQ2EtbXiZ1ZYF6r3UzL+ZeUyYyy0Tfiw wVAtrMMnYsh/EKaN/ReAS4eqYJ+egP/T0Z0SigS10sQqvP/E8jwhJlDqBqK8/O+RU0pk eOHNEzAjMyNoTq/aQBhefEf7oLwL39gVJqQS5nmAgqrUHUk3c9gjHdVZ15br2axJ/UA4 XLRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Q9FGcM2h; spf=softfail (google.com: domain of transitioning linux-nfs-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id a10-20020aa78e8a000000b004fa3a8dfff5si8547653pfr.172.2022.03.21.19.21.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 19:21:42 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-nfs-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Q9FGcM2h; spf=softfail (google.com: domain of transitioning linux-nfs-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 39A271CFD7; Mon, 21 Mar 2022 18:54:42 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235169AbiCVB4F (ORCPT + 99 others); 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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); } /* -- 2.35.1