From: Eric Dumazet Subject: Re: [PATCH net-next 2/2] net/sched: act_police: don't use spinlock in the data path Date: Fri, 16 Nov 2018 06:39:32 -0800 Message-ID: <65d29ecb-5d41-ad73-5849-4fd23fa1b8a0@gmail.com> References: <6d287f706fdcff76eb1e9a1c85ea6ce188db11d8.1536852493.git.dcaratti@redhat.com> <45d88e35-43f8-d9ae-4da4-de61c3591a62@gmail.com> <6ef73ea1-2f0e-b1c5-3a0a-1742db67b59a@gmail.com> <7ba53062-de84-a8f1-14dc-3c49a2480925@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org To: Davide Caratti , Jamal Hadi Salim , Cong Wang , Jiri Pirko , "David S. Miller" Return-path: Received: from mail-pf1-f193.google.com ([209.85.210.193]:34339 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728114AbeKQAwN (ORCPT ); Fri, 16 Nov 2018 19:52:13 -0500 Received: by mail-pf1-f193.google.com with SMTP id h3so4962905pfg.1 for ; Fri, 16 Nov 2018 06:39:34 -0800 (PST) In-Reply-To: <7ba53062-de84-a8f1-14dc-3c49a2480925@gmail.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 11/16/2018 06:34 AM, Eric Dumazet wrote: > >> + s64 tcfp_toks; >> + s64 tcfp_ptoks; >> + s64 tcfp_t_c; > > I suggest to use a single cache line with a dedicated spinlock and these three s64 > > spinlock_t tcfp_lock ____cacheline_aligned_in_smp; > s64 ... > s64 ... > s64 ... > > >> struct tcf_police_params __rcu *params; > > Make sure to use a different cache line for *params > > struct tcf_police_params __rcu *params ____cacheline_aligned_in_smp; Or move it before the cacheline used by the lock and three s64, since 'common' should be read-mostly. No need for a separate cache line.