Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3067589rwb; Fri, 9 Dec 2022 09:31:47 -0800 (PST) X-Google-Smtp-Source: AA0mqf4PRf2N2S9PESJ70iDtm4GdSEDctV3Cx5I1Q9TmdjheKsjnreYVRUHiyVtJPljPy6jsLkSm X-Received: by 2002:a17:902:7042:b0:189:cada:4294 with SMTP id h2-20020a170902704200b00189cada4294mr6573771plt.5.1670607106803; Fri, 09 Dec 2022 09:31:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670607106; cv=none; d=google.com; s=arc-20160816; b=TGoskc8Jm83MpOGAOXvzWtTXtcAFt4ipyqK6SxwBy890edsHGKVkpSYBwreugtAuBH rWBTyTdL1gC9RujbFyVr906bJv/hmH5VtWEQfyTO9LbMFHa+4OkNpyM6VJj6kdxstwVn dmgOD5a8GuX/VsC2zpub9awMLPcxjxXJWdvIyAwxicXw4c2UlUuEu5SRbYe1dU7GaBRY iT+l04jU8eCwL/PACgkBwx0xJpj3IcnV4snkjhJnOh6UbgyZV0z1qYac/J9AxZXLlfp8 koMoxRp4Qtp9shR/V3o6+gO68hBigH39cqtHzhdE0MgbhYkrqeSvnYjjlXsJ+z3ZibMd iOKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:user-agent:date :mime-version:references:in-reply-to:cc:to:from:subject:message-id :dkim-signature; bh=58/VjDZZoily/fkCPVeQuHIo3U3CJ3NHBYhVURQ6msE=; b=TR/3mRERo3BeKBMMVjaN/jf3DeauIX393H06TCWVVPib/2aO1GvjPg4bpFzGKIiwCy X3cxqU8LhOCKGDtX64d6nZkCX4mGhF1aUgjaPq4t/MmFe1gQeIGAtdK4en3be+6JplSs MR2tyAkgodK293kFDte9kwCvfH4lyN4zD0Y6tVA0HbB/KwTWQqKu1aYshPkR8xGvcRlw ZZpFJ/jGDMhtkmosVf4QDp19XtFZKOi87DHqgQNTFWn2w2rKsPeYGJqPA5CGZ9xbf9Rl AcAD6ZKB0Tr339Nk5qbYmj3uZBBtBtwO2c7Z5322mTVBKL81PhmcMGgTrWSemWdHrW/G 5ZEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Yd+y+3Rx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 q3-20020a17090311c300b00172cb948c68si2278216plh.227.2022.12.09.09.31.37; Fri, 09 Dec 2022 09:31:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=Yd+y+3Rx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S229807AbiLIQz4 (ORCPT + 74 others); Fri, 9 Dec 2022 11:55:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229783AbiLIQzw (ORCPT ); Fri, 9 Dec 2022 11:55:52 -0500 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 2A0252790E for ; Fri, 9 Dec 2022 08:54:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670604898; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=58/VjDZZoily/fkCPVeQuHIo3U3CJ3NHBYhVURQ6msE=; b=Yd+y+3RxOX41ySqFUi9gdtAxxGSuOWzgwo0O5sjuTSA4KciVcl7tzgMDhJYhruFN8JN4kJ v013RmpxhxBOjGB90nlFQbRyj/pdQBOMtbv6ammJ7PpxZi6WuBcMWZY+7av5+Q0vw8NVUj 1kA2YjYajTzoGTgSdAPrZX7g6i6Xsd0= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-37-IWEFw5ANPjGz74vi1rJlOg-1; Fri, 09 Dec 2022 11:54:57 -0500 X-MC-Unique: IWEFw5ANPjGz74vi1rJlOg-1 Received: by mail-qt1-f199.google.com with SMTP id ay12-20020a05622a228c00b003a52bd33749so4815474qtb.8 for ; Fri, 09 Dec 2022 08:54:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:user-agent:date:mime-version:references :in-reply-to:cc:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=58/VjDZZoily/fkCPVeQuHIo3U3CJ3NHBYhVURQ6msE=; b=jLyptIFoJoWowexOIHURV8WVjZKXTKum247RO5kqfJqNuJ7kYqNeA1qXxSp9jauvYC TCAEQmtlmhYdml3xM8HRH9TUuBszT1KHhGmOMfVj0QeB9WbJFjBh7iaYNm0N6bOqAeMM MVIzMAxMP4bWA7izCBoe/r986XvWG1PoD/hEY3VtKxF9I5Ls6qU5CsN1nHNaDSIzIAdw giRVJE0ZOH21BX9HUEknTl5tRK4S0lv8zRbtNzJWetdpIKU/3LCEON1MisPR5W41eugx UT5PF3g7k2zGouO7z9oaFiZYFjbtkeM1kF6kNC6RLv46QvBjoymIr1VzFxvswAz2Z5yL kpNg== X-Gm-Message-State: ANoB5plXTBp/wrlqj8Cxkw6MCsWJ8K0V5YsUuzgDAiD2uCBhh1UvqNu2 ThLdQsIkVLsS/BDO3rJyQ5Ia1/z9U3hP6lEojBBd87EZ5dvLNSkZxFUXlyYn2z16InjyAQLV1SM tV8IiO8rhXTOfeofLtiKYMKXL X-Received: by 2002:a05:622a:598f:b0:3a5:108b:4c0a with SMTP id gb15-20020a05622a598f00b003a5108b4c0amr8948887qtb.49.1670604896795; Fri, 09 Dec 2022 08:54:56 -0800 (PST) X-Received: by 2002:a05:622a:598f:b0:3a5:108b:4c0a with SMTP id gb15-20020a05622a598f00b003a5108b4c0amr8948861qtb.49.1670604896470; Fri, 09 Dec 2022 08:54:56 -0800 (PST) Received: from gerbillo.redhat.com (146-241-105-105.dyn.eolo.it. [146.241.105.105]) by smtp.gmail.com with ESMTPSA id h4-20020ac85484000000b0039cc64bcb53sm1192355qtq.27.2022.12.09.08.54.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Dec 2022 08:54:56 -0800 (PST) Message-ID: <9bb1cb8eff7d0e41230a48e01b1190a20602eb6a.camel@redhat.com> Subject: Re: [PATCH v1 3/3] net: simplify sk_page_frag From: Paolo Abeni To: Benjamin Coddington , netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski In-Reply-To: <79b1009812b753c3a82d09271c4d655d644d37a6.1669036433.git.bcodding@redhat.com> References: <79b1009812b753c3a82d09271c4d655d644d37a6.1669036433.git.bcodding@redhat.com> Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Fri, 09 Dec 2022 17:42:06 +0100 User-Agent: Evolution 3.42.4 (3.42.4-2.fc35) Content-Transfer-Encoding: 7bit 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, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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-kernel@vger.kernel.org On Mon, 2022-11-21 at 08:35 -0500, Benjamin Coddington wrote: > Now that in-kernel socket users that may recurse during reclaim have benn > converted to sk_use_task_frag = false, we can have sk_page_frag() simply > check that value. > > Signed-off-by: Benjamin Coddington > --- > include/net/sock.h | 9 ++------- > 1 file changed, 2 insertions(+), 7 deletions(-) > > diff --git a/include/net/sock.h b/include/net/sock.h > index ffba9e95470d..fac24c6ee30d 100644 > --- a/include/net/sock.h > +++ b/include/net/sock.h > @@ -2539,19 +2539,14 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk) > * Both direct reclaim and page faults can nest inside other > * socket operations and end up recursing into sk_page_frag() > * while it's already in use: explicitly avoid task page_frag > - * usage if the caller is potentially doing any of them. > - * This assumes that page fault handlers use the GFP_NOFS flags or > - * explicitly disable sk_use_task_frag. > + * when users disable sk_use_task_frag. > * > * Return: a per task page_frag if context allows that, > * otherwise a per socket one. > */ > static inline struct page_frag *sk_page_frag(struct sock *sk) > { > - if (sk->sk_use_task_frag && > - (sk->sk_allocation & (__GFP_DIRECT_RECLAIM | __GFP_MEMALLOC | > - __GFP_FS)) == > - (__GFP_DIRECT_RECLAIM | __GFP_FS)) > + if (sk->sk_use_task_frag) > return ¤t->task_frag; > > return &sk->sk_frag; To make the above as safe as possible I think we should double-check the in-kernel users explicitly setting sk_allocation to GFP_ATOMIC, as that has the side effect of disabling the task_frag usage, too. Patch 2/3 already catches some of such users, and we can safely leave alone few others, (specifically l2tp, fou and inet_ctl_sock_create()). Even wireguard and tls looks safe IMHO. So the only left-over should be espintcp, I suggest updating patch 2/3 clearing sk_use_task_frag even in espintcp_init_sk(). Other than that LGTM. Cheers, Paolo