From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5261BC7EE26 for ; Tue, 23 May 2023 02:13:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229830AbjEWCNW (ORCPT ); Mon, 22 May 2023 22:13:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232716AbjEWCNS (ORCPT ); Mon, 22 May 2023 22:13:18 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A1EDCA; Mon, 22 May 2023 19:13:17 -0700 (PDT) Received: from dggpemm500005.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4QQHmb1vQNzqSHT; Tue, 23 May 2023 10:08:47 +0800 (CST) Received: from [10.69.30.204] (10.69.30.204) by dggpemm500005.china.huawei.com (7.185.36.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 23 May 2023 10:13:15 +0800 Subject: Re: [PATCH net] page_pool: fix inconsistency for page_pool_ring_[un]lock() To: Ilias Apalodimas , Jesper Dangaard Brouer CC: , , , , , , Jesper Dangaard Brouer , Eric Dumazet , Lorenzo Bianconi , Daniel Borkmann , John Fastabend References: <20230522031714.5089-1-linyunsheng@huawei.com> <1fc46094-a72a-f7e4-ef18-15edb0d56233@redhat.com> From: Yunsheng Lin Message-ID: Date: Tue, 23 May 2023 10:13:14 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.69.30.204] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500005.china.huawei.com (7.185.36.74) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/5/22 19:45, Ilias Apalodimas wrote: >> On 22/05/2023 05.17, Yunsheng Lin wrote: >>> page_pool_ring_[un]lock() use in_softirq() to decide which >>> spin lock variant to use, and when they are called in the >>> context with in_softirq() being false, spin_lock_bh() is >>> called in page_pool_ring_lock() while spin_unlock() is >>> called in page_pool_ring_unlock(), because spin_lock_bh() >>> has disabled the softirq in page_pool_ring_lock(), which >>> causes inconsistency for spin lock pair calling. >>> >>> This patch fixes it by returning in_softirq state from >>> page_pool_producer_lock(), and use it to decide which >>> spin lock variant to use in page_pool_producer_unlock(). >>> >>> As pool->ring has both producer and consumer lock, so >>> rename it to page_pool_producer_[un]lock() to reflect >>> the actual usage. Also move them to page_pool.c as they >>> are only used there, and remove the 'inline' as the >>> compiler may have better idea to do inlining or not. >>> >>> Fixes: 7886244736a4 ("net: page_pool: Add bulk support for ptr_ring") >>> Signed-off-by: Yunsheng Lin >> >> Thanks for spotting and fixing this! :-) It was spotted when implementing the below patch:) https://patchwork.kernel.org/project/netdevbpf/patch/168269857929.2191653.13267688321246766547.stgit@firesoul/#25325801 Do you still working on optimizing the page_pool destroy process? If not, do you mind if I carry it on based on that?