From patchwork Wed Dec 2 22:53:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arjun Roy X-Patchwork-Id: 336520 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, USER_AGENT_GIT autolearn=ham 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 00547C64E7C for ; Wed, 2 Dec 2020 22:55:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A05DA221FD for ; Wed, 2 Dec 2020 22:55:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387743AbgLBWzP (ORCPT ); Wed, 2 Dec 2020 17:55:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387665AbgLBWzN (ORCPT ); Wed, 2 Dec 2020 17:55:13 -0500 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01577C061A4B for ; Wed, 2 Dec 2020 14:53:59 -0800 (PST) Received: by mail-pf1-x442.google.com with SMTP id b10so2202803pfo.4 for ; Wed, 02 Dec 2020 14:53:58 -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=tTNYrn4xDC+1b8MnNoT1J4xKmUKcP9Eh5NPYTUnTJa0=; b=pSWrKgeM4a2J7yDfcP1bJLvRANonp9ZNkbwuyL/a1ZVoJgMyb/F0FtVGrGUqbwv5iA vSdzqObjg22WvidLN0C/1tUEC8tz+hn1A4i2l7bdM2ncRGswL1tSaSvNZxfMUylTDfmF 56hFJjpoHe/LTZbXxsYK9mAGxNvI8XC/2GYLSSrtFXlrxXgB540FWhQFUzfbuQxHk10i 42K0i3+5zMhVbif+n6xPB05KpO7SLeyY1qTYBpJrQf/37+OchdUv5JhPYucyXHH7S2q4 fJ5ImHDUky/2neI0oAWuU07iqHAIXtemMEIBdH72rUkzUbjdNQSBgsC0Xi7Gx5p4lEfE Tvrg== 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=tTNYrn4xDC+1b8MnNoT1J4xKmUKcP9Eh5NPYTUnTJa0=; b=HTeDNcogpwqzf0B1I4JTlsMtJU6zOwtG4/Cy7MblUvPL6nc2nnOpwUuD5fa693dXBD NkW2Q2XVD+fWQdZ0km6Bcd3MovCfCVwwS0FYCTUopAc+sJKSKD7FS9MuUd0gfGPs8OCJ lwotUoybwzgsWOhh/sL0Ou/+tQ1k5V8XUzyLoJ5CKxmwU6Add0wpeu6i4ID3KcMF9VfB mu0l/b3w3nY5Ll94ZSL0W4yC7YTlrIkcWyt2wIsJxPudHaJDL9nmgJHdKJmCWx5Fjbb0 +LZFDtYTE+YN0bWK7T2Fm6E+ElfbKbaB0SsvDQHA2bRfl1FdiITmjEkvdOV0npnT1RT/ 8PnQ== X-Gm-Message-State: AOAM531t3q97FZBByQ9I5Lf4GPTk1HTS9fV77EnXdDdJYshbFuIqdt4g NWz/13O4gOeioMAMX20VImQ= X-Google-Smtp-Source: ABdhPJwvorPz2AGpeYt4WLp/V45wbXvCzd1VnVGY+5PV3OoxTeEUGQir2ljh82B3OMU3hqfFCzjgrw== X-Received: by 2002:a62:88c3:0:b029:18c:3203:efb7 with SMTP id l186-20020a6288c30000b029018c3203efb7mr426484pfd.33.1606949638634; Wed, 02 Dec 2020 14:53:58 -0800 (PST) Received: from phantasmagoria.svl.corp.google.com ([2620:15c:2c4:201:f693:9fff:feea:f0b9]) by smtp.gmail.com with ESMTPSA id i3sm39962pjs.34.2020.12.02.14.53.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2020 14:53:58 -0800 (PST) From: Arjun Roy To: davem@davemloft.net, netdev@vger.kernel.org Cc: arjunroy@google.com, edumazet@google.com, soheil@google.com Subject: [net-next v3 5/8] net-zerocopy: Fast return if inq < PAGE_SIZE Date: Wed, 2 Dec 2020 14:53:46 -0800 Message-Id: <20201202225349.935284-6-arjunroy.kdev@gmail.com> X-Mailer: git-send-email 2.29.2.576.ga3fc446d84-goog In-Reply-To: <20201202225349.935284-1-arjunroy.kdev@gmail.com> References: <20201202225349.935284-1-arjunroy.kdev@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Arjun Roy Sometimes, we may call tcp receive zerocopy when inq is 0, or inq < PAGE_SIZE, in which case we cannot remap pages. In this case, simply return the appropriate hint for regular copying without taking mmap_sem. Signed-off-by: Arjun Roy Signed-off-by: Eric Dumazet Signed-off-by: Soheil Hassas Yeganeh --- net/ipv4/tcp.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 4bdd4a358588..b2f24a5ec230 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -1889,6 +1889,14 @@ static int tcp_zerocopy_receive(struct sock *sk, sock_rps_record_flow(sk); + if (inq < PAGE_SIZE) { + zc->length = 0; + zc->recv_skip_hint = inq; + if (!inq && sock_flag(sk, SOCK_DONE)) + return -EIO; + return 0; + } + mmap_read_lock(current->mm); vma = find_vma(current->mm, address);