From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cong Wang Subject: Re: [PATCH net] ipv4: add reference counting to metrics Date: Fri, 26 May 2017 10:26:27 -0700 Message-ID: References: <1493934857-6693-1-git-send-email-xiyou.wangcong@gmail.com> <1494370451.7796.93.camel@edumazet-glaptop3.roam.corp.google.com> <1494371348.7796.95.camel@edumazet-glaptop3.roam.corp.google.com> <1495572267.6465.79.camel@edumazet-glaptop3.roam.corp.google.com> <1495665921.6465.95.camel@edumazet-glaptop3.roam.corp.google.com> <1495747655.6465.113.camel@edumazet-glaptop3.roam.corp.google.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Cc: Eric Dumazet , David Miller , Andrey Konovalov , Julian Anastasov , netdev To: Eric Dumazet Return-path: Received: from mail-wm0-f67.google.com ([74.125.82.67]:34309 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1948350AbdEZR0t (ORCPT ); Fri, 26 May 2017 13:26:49 -0400 Received: by mail-wm0-f67.google.com with SMTP id d127so5089896wmf.1 for ; Fri, 26 May 2017 10:26:48 -0700 (PDT) In-Reply-To: Sender: netdev-owner@vger.kernel.org List-ID: On Fri, May 26, 2017 at 10:13 AM, Eric Dumazet wrote: > On Fri, May 26, 2017 at 10:08 AM, Cong Wang wrote: >> On Thu, May 25, 2017 at 2:27 PM, Eric Dumazet wrote: > >> Just one nit below. >> >>> -const u32 dst_default_metrics[RTAX_MAX + 1] = { >>> +const struct dst_metrics dst_default_metrics = { >>> /* This initializer is needed to force linker to place this variable >>> * into const section. Otherwise it might end into bss section. >>> * We really want to avoid false sharing on this variable, and catch >>> * any writes on it. >>> */ >>> - [RTAX_MAX] = 0xdeadbeef, >>> + .refcnt = ATOMIC_INIT(1), >>> }; >> >> The code comment above is no longer needed since >> we have to initialize refcnt to 1, instead of merely for const >> section. > > I believe the comment is still needed, because normally we make sure > dst_default_metrics.refcnt is never touched (incremened nor > decremented) > > So its value should not really matter ? Oh, you're right, we always have the check on != &dst_default_metrics. > > I found that ATOMIC_INIT(1) was less ugly than the 0xdeadbeef Of course.