From patchwork Sat Jan 2 15:17:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 356085 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC9F0C43217 for ; Sat, 2 Jan 2021 15:23:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B71EE224D2 for ; Sat, 2 Jan 2021 15:23:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727096AbhABPWr (ORCPT ); Sat, 2 Jan 2021 10:22:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726573AbhABPWp (ORCPT ); Sat, 2 Jan 2021 10:22:45 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22906C06179F; Sat, 2 Jan 2021 07:21:31 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id c133so13165892wme.4; Sat, 02 Jan 2021 07:21:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BfcAWicfY3ps8Cp/gsA4qs7Avo53ajYGpXmNYv+JbSY=; b=h3b+ygyZOCMZuu/SSxyE2DWy3gO46XVTWVl20xf69BlLvp9dyAKaIzAwn7UmW26Kb/ Ljv0oHCBxsXqorvd1qYO/nb8M0kRw/9DQQx6p+tfKVVwfj+/6ysumrx+Cn1GhfAuSm9S v+7NBHal1hmJCfS5zl+1GhhdLI3hHTIpQnNfgkqSKgB/I81jGpD95EU2eneLMNlNY4IH FgNLFwinxLsO4rsFs6D3gm3ZQzQI71uYRosnGEz/aeZdan7BrrrEt08QP5adFhjqMouz JWKb4wWJuJfsKMdwtZJd30UVuxO9MV9x4ger8/HPOf50eWCLPwOaRdQ2MS3H02te9WbG ByKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BfcAWicfY3ps8Cp/gsA4qs7Avo53ajYGpXmNYv+JbSY=; b=iUIhtk48KJ91qOW1SIRED0JtIPiFZF8NEJuOfqnWGqMCK+zAZNdd1fhU92fgwuT2DG 9PBXqvjDiWe782iEWD4tWc8ohfieNJtqOeh+sNg1Ot0EJJH0MkkYh5V5kqj3Ab56rmyy 762777UFpVnPtlIoGd4/bfA1ThKlI62Bfu7oZoVk/YQcP45xti/QRNpPFmqgsbDqFQdO hedkU1tmvJRdAvR4HCBMT3CZxBKjTpYzK8aYXmio0HNyJtkEDtrJHF8Pl9IYNajScQiM R1HMnG1pbg2KTSzvlPgTCutKztof2Env3dugFah86w+7CvU5CZyJxFxQgv6kqfEmKWCI AO2g== X-Gm-Message-State: AOAM531RBiiVYPWqFz5buDAf/mf2b5mTHjlxEkuHIdgBuxQwDymOeglX zTosUaalT949LHXbi0ugBf/8MEVPtoOJTw== X-Google-Smtp-Source: ABdhPJz+w9pXtmdIRErhfXjecmNBpBoEj5ZToxSuo4zC0pqEv8F+jXoDdzGVYwWU0q45PiWTWmj+DA== X-Received: by 2002:a1c:6383:: with SMTP id x125mr19797365wmb.46.1609600889718; Sat, 02 Jan 2021 07:21:29 -0800 (PST) Received: from localhost.localdomain ([85.255.236.0]) by smtp.gmail.com with ESMTPSA id h13sm78671243wrm.28.2021.01.02.07.21.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Jan 2021 07:21:29 -0800 (PST) From: Pavel Begunkov To: linux-block@vger.kernel.org Cc: Jens Axboe , Christoph Hellwig , Matthew Wilcox , Ming Lei , Johannes Weiner , Alexander Viro , "Darrick J . Wong" , "Martin K . Petersen" , Jonathan Corbet , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, io-uring@vger.kernel.org, linux-kernel@vger.kernel.org, target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, linux-doc@vger.kernel.org, Christoph Hellwig Subject: [PATCH v2 5/7] iov_iter: optimise bvec iov_iter_advance() Date: Sat, 2 Jan 2021 15:17:37 +0000 Message-Id: X-Mailer: git-send-email 2.24.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org iov_iter_advance() is heavily used, but implemented through generic means. For bvecs there is a specifically crafted function for that, so use bvec_iter_advance() instead, it's faster and slimmer. Reviewed-by: Christoph Hellwig Signed-off-by: Pavel Begunkov --- lib/iov_iter.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/iov_iter.c b/lib/iov_iter.c index 7de304269641..9b1c109dc8a9 100644 --- a/lib/iov_iter.c +++ b/lib/iov_iter.c @@ -1065,6 +1065,21 @@ static void pipe_advance(struct iov_iter *i, size_t size) pipe_truncate(i); } +static void iov_iter_bvec_advance(struct iov_iter *i, size_t size) +{ + struct bvec_iter bi; + + bi.bi_size = i->count; + bi.bi_bvec_done = i->iov_offset; + bi.bi_idx = 0; + bvec_iter_advance(i->bvec, &bi, size); + + i->bvec += bi.bi_idx; + i->nr_segs -= bi.bi_idx; + i->count = bi.bi_size; + i->iov_offset = bi.bi_bvec_done; +} + void iov_iter_advance(struct iov_iter *i, size_t size) { if (unlikely(iov_iter_is_pipe(i))) { @@ -1075,6 +1090,10 @@ void iov_iter_advance(struct iov_iter *i, size_t size) i->count -= size; return; } + if (iov_iter_is_bvec(i)) { + iov_iter_bvec_advance(i, size); + return; + } iterate_and_advance(i, size, v, 0, 0, 0) } EXPORT_SYMBOL(iov_iter_advance);