Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6829301rwd; Tue, 6 Jun 2023 02:30:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ72HGEMEbo4bcbaNcNjpmiHvOS7xLVC/af2ULj0H9AKzJQr+xQXBarFdBGa9pD97etgGbrt X-Received: by 2002:a05:620a:20c4:b0:75c:b450:cd8 with SMTP id f4-20020a05620a20c400b0075cb4500cd8mr1312190qka.5.1686043858540; Tue, 06 Jun 2023 02:30:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686043858; cv=none; d=google.com; s=arc-20160816; b=BIS4zjxLN+O0O3e6l3nNO9qygaPgz604tNFogu593asO2egEP9IBCKU4eRNYfglLLU Pha8TgqpG01vUD+iu7/DPWHrErqCzujbHL9Q2Y8s1O9sjBra9c74EQTFJ7XvczdGR7Cr t59pyCXX1SE8pKYDbttCvqmnB+fSNBRkB8sVLr0Asn43u9HuoJjX23r4MsgrzhnKvkBv 75ew8vv+AZSQP3Haoi7N73o/X/X/+n/b09RtvOXt8y+RO1C7NJjm3K0mGgWHAShBcfy9 14SPtp1bKY3i/SNRlOxzfydMDxuFwPF6NP1br2uV1bnbQm93zY3YNplbu79P8dblSdqX sRmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:content-id:mime-version:subject :cc:to:references:in-reply-to:from:organization:dkim-signature; bh=1FjaNZ7+M8ixgklXKY7vWvF9ET0ANZmsx5DhZNKDjLs=; b=LQjuLaP+Q3tgq6S2iBulWFF7tCt3c25MXwH1vTVlwas9zTvYbm1iSDtPkoMnwhSDZ3 Etq0VV4AIoK5E52M55kPv8XQ3C9APlBQbnxWK6A1KtL9SVVSiqjK1olwWefS5HC0tvAs 9R6xnRqjdpZ5UPGk0vmS7mGVWj3ZYkzUxryneO+Y/FxtBBzHiorcte/QdOVm2O4djC3W eyc5j1RDci5KKVIrmpB/9z+9USvQceWj6eJL1HoiQJw+wrbFnt16Mz0sejevEB1DsBue OUb7yL2q1Z+9GRLDyLRvx3PnjzFxR0Ua1bZ7oFwB3W1n0AtBK7MT9PKGbCFkGuJ8m/CF nCoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Rx0hf1JA; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a13-20020a05620a124d00b0075c9cb484edsi5653686qkl.628.2023.06.06.02.30.42; Tue, 06 Jun 2023 02:30:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Rx0hf1JA; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235891AbjFFJZo (ORCPT + 99 others); Tue, 6 Jun 2023 05:25:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231700AbjFFJZo (ORCPT ); Tue, 6 Jun 2023 05:25:44 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B122FE49 for ; Tue, 6 Jun 2023 02:25:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686043505; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=1FjaNZ7+M8ixgklXKY7vWvF9ET0ANZmsx5DhZNKDjLs=; b=Rx0hf1JA3jaTb8gqEvPVy1fCrVF5vPw/KsKAy6UFz8hV/18fOnSMK+gToHQp0img9kiHNK /iHKinTiOgmngz3IoEiEGnlZswpTIos5Y9f1suJBfd9rukTxSwkEYsn4+i+VdtJUgv6J2J PH4iqXPBgyHXMcyBq4CP35nsrxfvOGM= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-435-THFJdaEpPA-GwDd5F7Zibg-1; Tue, 06 Jun 2023 05:25:01 -0400 X-MC-Unique: THFJdaEpPA-GwDd5F7Zibg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9D65A1C068EC; Tue, 6 Jun 2023 09:25:00 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id 01E5E492B00; Tue, 6 Jun 2023 09:24:56 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: References: <20230530141635.136968-1-dhowells@redhat.com> <20230530141635.136968-11-dhowells@redhat.com> To: Herbert Xu Cc: dhowells@redhat.com, netdev@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-crypto@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next v2 10/10] crypto: af_alg/hash: Support MSG_SPLICE_PAGES MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1845448.1686043495.1@warthog.procyon.org.uk> Date: Tue, 06 Jun 2023 10:24:55 +0100 Message-ID: <1845449.1686043495@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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-crypto@vger.kernel.org Herbert Xu wrote: > > - if (limit > sk->sk_sndbuf) > > - limit = sk->sk_sndbuf; > > + /* Don't limit to ALG_MAX_PAGES if the pages are all already pinned. */ > > + if (!user_backed_iter(&msg->msg_iter)) > > + max_pages = INT_MAX; If the iov_iter is a kernel-backed type (BVEC, KVEC, XARRAY) then (a) all the pages it refers to must already be pinned in memory and (b) the caller must have limited it in some way (splice is limited by the pipe capacity, for instance). In which case, it seems pointless taking more than one pass of the while loop if we can avoid it - at least from the point of view of memory handling; granted there might be other criteria such as hogging crypto offload hardware. > > + else > > + max_pages = min_t(size_t, max_pages, > > + DIV_ROUND_UP(sk->sk_sndbuf, PAGE_SIZE)); > > What's the purpose of relaxing this limit? If the iov_iter is a user-backed type (IOVEC or UBUF) then it's not relaxed. max_pages is ALG_MAX_PAGES here (actually, I should just move that here so that it's clearer). I am, however, applying the sk_sndbuf limit here also - there's no point extracting more pages than we need to if ALG_MAX_PAGES of whole pages would overrun the byte limit. > Even if there is a reason for this shouldn't this be in a patch by itself? I suppose I could do it as a follow-on patch; use ALG_MAX_PAGES and sk_sndbuf before that as for user-backed iterators. Actually, is it worth paying attention to sk_sndbuf for kernel-backed iterators? David