Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp91244iof; Sun, 5 Jun 2022 22:05:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqam2/hoHEMye1KR4Uijr2i9rnHxFAtt1oNmj5SX34R1yVha4dEVUFX7B7xOij3XGTwF11 X-Received: by 2002:a17:90b:3ecc:b0:1e3:4b89:e576 with SMTP id rm12-20020a17090b3ecc00b001e34b89e576mr31655037pjb.183.1654491914813; Sun, 05 Jun 2022 22:05:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654491914; cv=none; d=google.com; s=arc-20160816; b=q05kjdtU3koOyjAaXPyYV1v7194uSZytl/xgCvd/MQSlgCx0zulOoVGd3M7E+IfWxB kCfpU1sl2u5WuV52Q/pmNkI/NL7GCQgHyJNC7bz9OgCilQiC7OvxJ+PPKxAimq6W+pDq PcvYSbIhUSZul9L8MwUViDMf5a5IZG6ofRRxPxx51wxaGTGiVfJpEOaZ1Va+qIzsf7tP jN6cblDKXVTvW/eSHxYOLYsOZbNuu015oOa4RIlGft4khe8xxV9r83eQnJxbuPFX43Zy EWWwcntahQyCsWKjafcvDmQk7mHcZOFUdpVEsTPag3Zv5xESqY2/TBgZeZJW1jMwX+zs UCow== 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 :user-agent:references:in-reply-to:message-id:date:to:from:subject; bh=QAHKm/gWez0ZwbJk0ZqPss68f3vSQap3O0Fo1D75eUI=; b=M7+h6mxOzNCxMFx/4FU95ftrC/jo2KI87M1t2qyTnDj93pBvGJNci0uUTj7WQgQNh4 zL+GetmVhP5hqf73M+9PXZqRWxF8jR25gmE+L2LnR/ttR9qe9uLJcOmujgR50XZkZAEK KRitkthY06C625B8IroN0AM6y4XRPkO0F2BPaIvobDKyF605q3+mDUWB+Qt0sxGIqw9d /Rk/+ZSJjGzF5ayjck7tiksuyd3MRVh3N2sQ3PjNBIBYoMLzJOSc/gG/9I/VRcA9+j+J vC92n2sb2sydiIPrjN3z+ajAbuViqoiFgCgyWtZSWTMeE5xae38II0iJ1bjlaA58VG/+ QysQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id d3-20020a634f03000000b00383f92e1f96si5484058pgb.79.2022.06.05.22.05.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 22:05:14 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3DA9D1207F7; Sun, 5 Jun 2022 21:14:11 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344478AbiFET6k (ORCPT + 99 others); Sun, 5 Jun 2022 15:58:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347132AbiFET6g (ORCPT ); Sun, 5 Jun 2022 15:58:36 -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 CEAD04D9C6 for ; Sun, 5 Jun 2022 12:58:35 -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 50798B80DCA for ; Sun, 5 Jun 2022 19:58:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E759FC385A5 for ; Sun, 5 Jun 2022 19:58:32 +0000 (UTC) Subject: [PATCH v1 2/5] SUNRPC: Optimize xdr_reserve_space() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Sun, 05 Jun 2022 15:58:31 -0400 Message-ID: <165445911199.1664.12318094116152634589.stgit@bazille.1015granger.net> In-Reply-To: <165445865736.1664.4497130284832282034.stgit@bazille.1015granger.net> References: <165445865736.1664.4497130284832282034.stgit@bazille.1015granger.net> User-Agent: StGit/1.5 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 The xdr_get_next_encode_buffer() function is called infrequently. On a typical build/test workload, it's called about 1 time in 400 calls to xdr_reserve_space() (measured on NFSD). Force the compiler to remove it from xdr_reserve_space(), which is a hot path. This change reduces the size of xdr_reserve_space() from 10 cache lines to 4 on my test system. Signed-off-by: Chuck Lever --- net/sunrpc/xdr.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c index b57cf9df4de8..08a85375b311 100644 --- a/net/sunrpc/xdr.c +++ b/net/sunrpc/xdr.c @@ -945,8 +945,13 @@ inline void xdr_commit_encode(struct xdr_stream *xdr) } EXPORT_SYMBOL_GPL(xdr_commit_encode); -static __be32 *xdr_get_next_encode_buffer(struct xdr_stream *xdr, - size_t nbytes) +/* + * The buffer space to be reserved crosses the boundary between + * xdr->buf->head and xdr->buf->pages, or between two pages + * in xdr->buf->pages. + */ +static noinline __be32 *xdr_get_next_encode_buffer(struct xdr_stream *xdr, + size_t nbytes) { __be32 *p; int space_left;