Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp9912708rwp; Thu, 20 Jul 2023 11:32:40 -0700 (PDT) X-Google-Smtp-Source: APBJJlEQNWT6cHziE68qg1Ji+RmjT4lc4OTblBcrLLwUMoB8JukmgQNgR3KWfnupr6VgoJXp6CBJ X-Received: by 2002:a2e:a28c:0:b0:2b4:45bc:7bd with SMTP id k12-20020a2ea28c000000b002b445bc07bdmr3120269lja.4.1689877959969; Thu, 20 Jul 2023 11:32:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689877959; cv=none; d=google.com; s=arc-20160816; b=I2GccxKw1TfrL1j5nRb1N3mT7s7CFfO7eFRTVEXacYSZqDneMk00+zEWJn16wTRx7z 1FWvhh/Cc507UWSQnPyHKIOvB83VWCVaSSXPfKSwREeymQSa72jAaKWqXNzFdDmGhFJl n3auC2aUv0LPmh2N0P+BgA9ggzhRG3vpl80Tcb5s6EjhPHNP4E9j6DKfnti6hPwyOWzh wNCrV9i1BIfKkDPxif/4meQ+GpPvkP+1htn7orJ6DX6DWv51VsAqnX7IBtqTaN5ZJWJL AsBCCuOXzpnKgmFg0cUj8ZoCPeZPe6PBTvIdcwBVZWmqMcUYIMe5w7mLlDaDg2/Uh32i 55MA== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=FJ3RgAuNkLZtHjNyO4hYZ7vuryU+Lexw5qEgP3XD5BA=; fh=AKzmLsXZS/AnmGquYecMciHff2P/b3shPdLwpMVWlVI=; b=zWdxPukqWDW8I2qnhE8BD2gdhQJUOMXmorVk7vkfSQe0At3B470F14VuUOIQiP28Iu HZIiJ2ujz5mEJx0dwIBYFKG9aqW8jNBfKQ/pP60Gi0vaA+OgvG/e/FhiAE5ZaUOQifkU jGJXYcGUQwI2jDT540obggoSMB8IKNr27d6YM711uSZiDAJ9SgP5eIF4Hjvd5ig+OQQ3 ZnXRExXyLIyQOv7NLaqRVG9GqhvtmqRoHercv2MYiSHHxM7p+6x98owSwsonIQ80vQe3 vsqpPPtX1IY2sEFz9ZvslK45OY0HOFKBQ4lppxvXKOhBPfONiM1plM4PK/oZJGEgfFJu b7jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Q9i2KlNi; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h23-20020a170906719700b00993199125d8si1063536ejk.378.2023.07.20.11.32.15; Thu, 20 Jul 2023 11:32:39 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=Q9i2KlNi; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229640AbjGTSAd (ORCPT + 99 others); Thu, 20 Jul 2023 14:00:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231562AbjGTSAb (ORCPT ); Thu, 20 Jul 2023 14:00:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22E38270D for ; Thu, 20 Jul 2023 11:00:30 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B257C61BB6 for ; Thu, 20 Jul 2023 18:00:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B174CC433C7; Thu, 20 Jul 2023 18:00:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689876029; bh=7zlXtpjQE5GsiUCG8T5VeQsjP7xxM1cSIbwNm1yLxBU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Q9i2KlNic8DT0aV6wei/pn/69NnpnLEOl6A5KpT0D+5gBE5EQ75jsSPR2pszdDquy h0Vr8sba6J3Z8Z6XUGYoqxiTYSvYq/y+u3YPm21zno40p5GItvroYgfGafZxv2OZdQ NnROMTed50T0p4vtabWit1SP/F5q4TVbmVKy9UpfTC3qo676e0x5oda7gb++e3Bnc+ DqL86OoukRxtv1Nt4UKGoVBdt0YDTPzQuD4oo9eniO++HlR3BKBipBd70U4zH3FepH oRGNqovTUNhPvvjJ52w35hqz4LV0ybJhcUEjw9ZGA4ggDpXYqRP8Prp8v4fG3Lj/y2 NKsx0/bGGfvsg== Date: Thu, 20 Jul 2023 11:00:27 -0700 From: Jakub Kicinski To: Alexander Lobakin Cc: "David S. Miller" , Eric Dumazet , Paolo Abeni , Maciej Fijalkowski , Larysa Zaremba , Yunsheng Lin , Alexander Duyck , Jesper Dangaard Brouer , "Ilias Apalodimas" , , Subject: Re: [PATCH RFC net-next v2 7/7] net: skbuff: always try to recycle PP pages directly when in softirq Message-ID: <20230720110027.4bd43ee7@kernel.org> In-Reply-To: <8e65c3d3-c628-2176-2fc2-a1bc675ad607@intel.com> References: <20230714170853.866018-1-aleksander.lobakin@intel.com> <20230714170853.866018-10-aleksander.lobakin@intel.com> <20230718174042.67c02449@kernel.org> <20230719135150.4da2f0ff@kernel.org> <48c1d70b-d4bd-04c0-ab46-d04eaeaf4af0@intel.com> <20230720101231.7a5ff6cd@kernel.org> <8e65c3d3-c628-2176-2fc2-a1bc675ad607@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII 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_BLOCKED,SPF_HELO_NONE,SPF_PASS,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-kernel@vger.kernel.org On Thu, 20 Jul 2023 19:48:06 +0200 Alexander Lobakin wrote: > >> My question was "how can two things race on one CPU in one context if it > >> implies they won't ever happen simultaneously", but maybe my zero > >> knowledge of netcons hides something from me. > > > > One of them is in hardirq. > > If I got your message correctly, that means softirq_count() can return > `true` even if we're in hardirq context, but there are some softirqs > pending? Not pending, being executed. Hardirq can come during softirq. > I.e. if I call local_irq_save() inside NAPI poll loop, > in_softirq() will still return `true`? (I'll check it myself in a bit, > but why not ask). Yes. > Isn't checking for `interrupt_context_level() == 1` more appropriate > then? Page Pool core code also uses in_softirq(), as well as a hellaton > of other networking-related places. Right now page pool only supports BH and process contexts. IOW the "else" branch of if (in_softirq()) in page pool is expecting to be in process context. Supporting hard irq would mean we need to switch to _irqsave() locking. That's likely way too costly. Or stash the freed pages away and free them lazily. Or add a lockdep warning and hope nobody will ever free a page-pool backed skb from hard IRQ context :)