Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2788759ybl; Sun, 26 Jan 2020 10:46:18 -0800 (PST) X-Google-Smtp-Source: APXvYqwe/uls7EC9P405MuXzufzXuaE+QV7xiALO1fLZIID+FqAFbX/UixlRNKaIJwXT1Lx5g3Uf X-Received: by 2002:a54:4e1e:: with SMTP id a30mr5376585oiy.53.1580064378214; Sun, 26 Jan 2020 10:46:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580064378; cv=none; d=google.com; s=arc-20160816; b=a16SdoxRub1HOLIeUCRxr0bDeZYVl9A/ewFwqVlkFCYmceD0ocy+BSW46JspkKLaF7 dPh5zlA3qm9HEz2vhzt5hFp3k8OvTu6GQe9OQjLau+gUVKXB/MNTeNMrDKWZZ5Fbuz6d dyw35f7lHm1kiL5MnOXbyJdM4dRU7vSgd/NNkr3gMpeOBJeCNQ/evcoz5K1HKYVA8NJm z5IkPzr73gtqYQ1ltudvVzP02UqYv+nu6ffi/pxCYFFZ8/tRhpsreY/PxHDQem84Cdqj J2nsJZI5HqZQoE5cu6oO57clVicyQH2RcNuWBe8ZNS3gxY4DyltjEHnMobCvAXRx2Ajc YKmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=i69aVqNtUh0aH4/EUSRDvf/FER9Hz68ISkhaUxUzTl0=; b=Y5N8YsQSInLZ4IzjnmTdCyQpuBd6kiYCNFwywdxReQAWmsBWVgMg6foF5y2r2csTGo 4pvmaxV300R/Ag8YIa0HfZlSY/63Wmze5MywvAFmTz4mX2YmQ4jpTEBfv6w51mzdVakp d3YOy/UYI7ANTEn97sRep2MeMwBiI3M3jrWDE5Uyyr9e7+fbnntCtnJZ+F13tJXVPoDK GhSahSrVoG1N/Md4IHIrmdwoMYGDKeFLOQgXhJo1E3Y1eEDhMVxtP9FCsfam0HwdLC3E lWlVi/UbZWop6bPssbPjLrszB52/vladFpgyxOUkhHc9tcJJwhJ4qslhUH2Zr/J+dOeb A5YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=rMfvEh8T; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u13si2012416otg.56.2020.01.26.10.46.04; Sun, 26 Jan 2020 10:46:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=rMfvEh8T; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727233AbgAZSix (ORCPT + 99 others); Sun, 26 Jan 2020 13:38:53 -0500 Received: from mail-yw1-f67.google.com ([209.85.161.67]:37416 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726181AbgAZSix (ORCPT ); Sun, 26 Jan 2020 13:38:53 -0500 Received: by mail-yw1-f67.google.com with SMTP id l5so3714118ywd.4 for ; Sun, 26 Jan 2020 10:38:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=i69aVqNtUh0aH4/EUSRDvf/FER9Hz68ISkhaUxUzTl0=; b=rMfvEh8T4b186lRHcWlnCCdlJg9db7RjBiyF5TCaQz1NcahGJQ7eCMmDE/JxwOTl7b LHizr5TWq5uqwSzp8Xk0MsEgWlBAejc5L0ULiKQk/ZD9n2y0doi/z55xP00bj3yv3Ava L1t7HDea0d8F2i15NqsG2tcjSbJpeFciT4k6Js5l0jnPrIJaQ1FOAirbv1uves9uyh2Z o3144kE6biOVCtOgZVGZn6xIrQgN6laceEyhtJJnAEV5rVe9ujeKKBx7s3pYa1nxQgzf K2Sjc9L5ypLwirkXI9cgkeeANEbDCpTBHHhXM+dSdh4vjzNWV6apbmPXhJ3d+idb2OX+ 959g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=i69aVqNtUh0aH4/EUSRDvf/FER9Hz68ISkhaUxUzTl0=; b=Eat9MpAO0OhHL5csVs5A6j3x2BjsUFWQB1bJWkGp3nyV4d585dGr1aw4a0hkhe3ytY /kBYJaTLKCHelKHc002SRQRkiiZk4/up1E3ZhqN2RUuKz1I5/xI1Q/1Si9O0U5KeL/vE fqDFJXcdNnjElClg5RATdbt5x170OJGJoSh0YpV+mIrc3/HATdduQMtzNmPyF8uP827C YPuI89b0KIii4gAcZOTFmcBZlMv3drgC8VSef26p6otz/wfEMgY862htIIjznz5MCto+ FhCo4jolVi+E9C2JpTsHNzcZTtR+myrW6YEvrSZjTGtlirZcZfUzY4EvnJEcPWeMKuV6 Gqlw== X-Gm-Message-State: APjAAAUWSUZFPypav6WJeoS92JOTGnm/hCPRQXOdm0VFbZ0TNPTsbew6 WgrBCNSgdC0X3kYcLScMZ0cfhU2ln+8jb24Chgd7Sejb X-Received: by 2002:a81:53d7:: with SMTP id h206mr8970498ywb.92.1580063932400; Sun, 26 Jan 2020 10:38:52 -0800 (PST) MIME-Version: 1.0 References: <20200124093047.008739095@linuxfoundation.org> <20200124093207.912523612@linuxfoundation.org> <20200126182917.GA26911@amd> In-Reply-To: <20200126182917.GA26911@amd> From: Eric Dumazet Date: Sun, 26 Jan 2020 10:38:41 -0800 Message-ID: Subject: Re: [PATCH 4.19 625/639] packet: fix data-race in fanout_flow_is_huge() To: Pavel Machek Cc: Greg Kroah-Hartman , LKML , stable@vger.kernel.org, Willem de Bruijn , "David S. Miller" , Sasha Levin Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jan 26, 2020 at 10:29 AM Pavel Machek wrote: > > > > - po->rollover->history[prandom_u32() % ROLLOVER_HLEN] = rxhash; > > + victim = prandom_u32() % ROLLOVER_HLEN; > > + > > + /* Avoid dirtying the cache line if possible */ > > + if (READ_ONCE(history[victim]) != rxhash) > > + WRITE_ONCE(history[victim], rxhash); > > + > > Replacing simple asignment with if() is ... not nice and with all the > "volatile" magic in _ONCE macros may not be win for > everyone. [Actually, I don't think this is win here. This is not > exactly hot path, is it? This is a critical hot path, eg under DDOS attack. > > If this is going to get more common, should we get > WRITE_ONCE_NONDIRTY() macro hiding the uglyness? > Sure, but we do not add macros for stable patches, usually. Honestly, WRITE_ONCE_NONDIRTY() looks ugly to me. Note that the KCSAN race might be solved in another way when data_race() is available.