Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2387649pxp; Mon, 21 Mar 2022 18:48:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYwJ0utlhht84lMoDBqijpsPleXxufAmfDkAjWR4T+16RUuGdOTEX7lDbq13ml7q87Nx1F X-Received: by 2002:a63:4d63:0:b0:380:fd6b:5893 with SMTP id n35-20020a634d63000000b00380fd6b5893mr20826243pgl.233.1647913719207; Mon, 21 Mar 2022 18:48:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647913719; cv=none; d=google.com; s=arc-20160816; b=L3wWmCz/TwDpTItofISkOw9c/lWQHqvI0QrbPGWXIh+RL5gTA2RRx/7omeZhAlmRlj 5KNO2e2L0rzrC7naBYLV94MCgxZ9OjC+4Tp61vmicVsZ2lAGuR8m9IDUw2lhqibB0ntZ 7tLva76fQSR8z6pOd2JAcVpi6ghNn2+gmvruDGUQvvyJN8cMBwRSBTvSuw6DPJMmX+s6 qKCKF1g7tpshTi+btp+lGFpF/gxHRi1eJit6uNFdGTC/qLl5/P9mg3UeLCJczYO5DSbc R4bpuNBS73UuQXb/w8GoNh0QVwx5oS3DPBAqerUpS34x9HZs/25seg5okJ/erzjK99f/ 46Gg== 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=0A/2zDyvvjcWZTIGO8zmadne1y7QY80G7q9klLGjrXGH61MqhzNU9NdAS7Lmr466Jy 2tOhnEQvfd148vZBH+im8Qi6LE1FbWnEv0Y7mJebDC+u2sYc//rVVWgy0SJrt2Nkkv57 UqZAW9EXT3i+9FDnotsY2ard5udgn8pROIxgAP6n1Uj2OYKf25rX2gF8V7NBeN6zVSek Jq2J8jtQxY5z86sVlSYcHCM4XE0enFe7qZdR0Qhjhqm2tukGlff4xNAM83qI0sqNjm6j ydErU2sjQAXnsY0pbeIMIkje6fxupHDG84a147AIVYkUQHRbLbvxt3mWsamq65BOXbUq 7G4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=o2aggUlH; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id g21-20020a63e615000000b003816043f0a8si15339980pgh.669.2022.03.21.18.48.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 18:48:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=o2aggUlH; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:18 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 3A4012A708; Mon, 21 Mar 2022 18:22:35 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234636AbiCVBX4 (ORCPT + 99 others); Mon, 21 Mar 2022 21:23:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234638AbiCVBXz (ORCPT ); Mon, 21 Mar 2022 21:23:55 -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 C98E71D0D4 for ; Mon, 21 Mar 2022 18:22:28 -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 73135B81B01 for ; Tue, 22 Mar 2022 01:22:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CCA15C340F0; Tue, 22 Mar 2022 01:22:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1647912146; bh=DrZNvoTWRqfjg6xxjhNfSiAQdezk+5CXJVWZ5lfbe1c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o2aggUlHIhfgQsKsqwFhfvqqkWLvsaBBGwVqAlTil+IsTGZlqBlLVO3Wt62YE2A+D sKjHMcerIBASOdIEa7oZKfzNreczk+sGDH7DEYn5Tdl48z3E5p49fLvBiMLGb92Qpc 54BArMtBVAaAuIGDOiRbMoqSliMgmsCeuNPg3NU5Pf/ZY6Ipx/7rCYoFRws05g1dg3 0g907fjQ0MXcj+XkhWHtqpVm+LVuVkcLZA8CwgBzxiFYVdnrVIhbDX5fMtZrTin0Rv lA4cPXq6Wsz+L/NUDwciujoDAXH5GihOv2hEXF9/6qHFX0HDPl2KebVggqvybAItFM 13pWZQ8RLYGtA== From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Cc: Neil Brown Subject: [PATCH v2 2/9] NFS: Fix memory allocation in rpc_alloc_task() Date: Mon, 21 Mar 2022 21:16:11 -0400 Message-Id: <20220322011618.1052288-3-trondmy@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220322011618.1052288-2-trondmy@kernel.org> References: <20220322011618.1052288-1-trondmy@kernel.org> <20220322011618.1052288-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