From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38C293C1F; Wed, 6 Aug 2025 04:00:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754452849; cv=none; b=hRvl80ndC8CnKzmOAPlaE4Xr92/S/o2MeK+acKodjwEFs9sjMmR9k23DtY+ruoqSrYYI+PDDXrH4N6v4dTmOurK5TiDFgRZul0RFDug5QvyBCiOYepnxLzgJr/0kj7bHsfvP0BbtN4bvYEaXfL1EzQoMpfqHAWCrFQabFEZX774= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754452849; c=relaxed/simple; bh=Yuw8bOEfvha+uWGO6FK0lOegX/jPVsfD62YLbYYk224=; h=Message-ID:Date:MIME-Version:CC:Subject:To:References:From: In-Reply-To:Content-Type; b=pvRWdVahp7VP2mRSCUJaeRHnLwnHSYTqPU+YXjXhLzcRJ3liNtYr/7Y+XU6r81oac2MkOgNjMNCjbA+xwzGLE3nrIGr2CdvYE3p2UkM+bzVDAq64DcE5eOSdzkXESF/iVx571HUZYozhGDIIzQ3L1miOdLs+AjH2z9U5+qEqRNE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4bxc1y55p4z13Mwn; Wed, 6 Aug 2025 11:57:26 +0800 (CST) Received: from kwepemk100013.china.huawei.com (unknown [7.202.194.61]) by mail.maildlp.com (Postfix) with ESMTPS id 87A2B1401F4; Wed, 6 Aug 2025 12:00:41 +0800 (CST) Received: from [10.67.120.192] (10.67.120.192) by kwepemk100013.china.huawei.com (7.202.194.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 6 Aug 2025 12:00:40 +0800 Message-ID: <3aa80a19-d2cd-47a2-aaf9-4bc438b7656b@huawei.com> Date: Wed, 6 Aug 2025 12:00:40 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird CC: , , , , , , , , , , , , , Subject: Re: [PATCH V2 net 2/3] net: hibmcge: fix the division by zero issue To: Jakub Kicinski References: <20250802123226.3386231-1-shaojijie@huawei.com> <20250802123226.3386231-3-shaojijie@huawei.com> <20250805181446.3deaceb9@kernel.org> From: Jijie Shao In-Reply-To: <20250805181446.3deaceb9@kernel.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: kwepems200001.china.huawei.com (7.221.188.67) To kwepemk100013.china.huawei.com (7.202.194.61) on 2025/8/6 9:14, Jakub Kicinski wrote: > On Sat, 2 Aug 2025 20:32:25 +0800 Jijie Shao wrote: >> static inline u32 hbg_get_queue_used_num(struct hbg_ring *ring) >> { >> + if (!ring->len) >> + return 0; >> + >> return (ring->ntu + ring->len - ring->ntc) % ring->len; > This should probably be a READ_ONCE() to a temporary variable. > There is no locking in debugfs, AFAICT, the value may change > between the test and the division / modulo. Yes, there is indeed a very short time window. I will add READ_ONCE() to ring->len and read it only once. Thanks Jijie Shao