Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp2645775imd; Fri, 2 Nov 2018 15:16:15 -0700 (PDT) X-Google-Smtp-Source: AJdET5ds6DjOVhGHhopTdBnBoOCIPzcN8J7M5QS3Ea9fS99tYWx0GfTQlkdwpN2Yq1quEu32E+AB X-Received: by 2002:a17:902:e201:: with SMTP id ce1-v6mr12878526plb.47.1541196975072; Fri, 02 Nov 2018 15:16:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541196975; cv=none; d=google.com; s=arc-20160816; b=sIlivFvBAMr/IBr1nQoCY9huFXqF8UZkcwfyNNFpjxxsM1Gdji7Bgf2Ds8stNtxqpg nc3syogxRAsN8ZL8YywmoFwQAvtIKma8jZe7HueOWekDlpTogKUQmTTuSRLlAEplkJIW TR6ALSFbqUJqxiCCBMTk13aIMIq6Hch7iKcfs9vExHYTUUv4jR1jYdPB/dCZ/kPmpesx ZP4CcGXgFivG7HTs4VMzt25Lw1VyEwD4ewEf1RiNkx/plsUi4sa8QTqTTNdqpTNPHPNx s5FUG3Eu1V1rNR4c8eMHS+J+hzUFDD7wjO6HH6Rrf3hKxfHTCmFfs7dju8QkGikAYqbu imzg== 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 :references:in-reply-to:mime-version:dkim-signature; bh=+36MGkBJOIyLiqLmdqmm6g8gRAPLYxbbx/nV3fDTvsU=; b=R6Wep7hLmoJ4QNHQ5cPoTLjPQJ5poqzsgMsgPUYvCAc2EOl/FSxHLsjomsEbALslH4 ylFEawbV7Zuv/C1K3s2OFfpJv6asrmWGQZIoJp6YrRfRkV0PKSRolZC0SEzTsy0dooBa DQWo5aUG+i8lcuMQODSYJg4xkhbSmL8tkBogEW3IoGnvoZZpDiVMxFswKZnW+Zhxc9Cf nVOrNR9bbkjlXAn61+rkcJ6nbwjO1xHZ7gC2nPjDQbtPjv/xX3zRwWPGpRFvAKz7NE5F J9L4NCp0FB598BEau2v2jEpNxi7kEXdwBErfV4A7c/OwE4zLBWXxyDe4yjeE/GIXbHYz uf+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=ZOC0Ew1d; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r22-v6si34089794pls.185.2018.11.02.15.16.00; Fri, 02 Nov 2018 15:16:15 -0700 (PDT) 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=fail header.i=@gmail.com header.s=20161025 header.b=ZOC0Ew1d; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728369AbeKCHYH (ORCPT + 99 others); Sat, 3 Nov 2018 03:24:07 -0400 Received: from mail-qk1-f194.google.com ([209.85.222.194]:42298 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726083AbeKCHYH (ORCPT ); Sat, 3 Nov 2018 03:24:07 -0400 Received: by mail-qk1-f194.google.com with SMTP id u68so5472394qkg.9; Fri, 02 Nov 2018 15:15:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=+36MGkBJOIyLiqLmdqmm6g8gRAPLYxbbx/nV3fDTvsU=; b=ZOC0Ew1drWhpzkD5IdzBEMBakNKlmGP27BKtECZX/0IJ5QFqlI9em4YuSaNYAjumsb lM/38fo/vDCYDELKNWV5vi8K4ljBGgMLOHvM6gknydgSMVZkydC7tCVAFQuKFIgC8ZBT 2dsBhog/+/WzUvpMUzy0SdS4zArVNQcnvISiK4DJCiMQ5J2IYGPHNujNhcokeZ54hIVV hiECMdjHtvm80q/q2We7lb7AA/KRbC3ibJXrUZxchUABKZdWWjbuWgE6AYBn4CqeCGIv GQ1neEBrnQtBLsFqbOj0cKQPvcBGFdm2XqmeDIN7KeOhlqBlDFGX5+ep+/JymWp+Q9zA jrRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=+36MGkBJOIyLiqLmdqmm6g8gRAPLYxbbx/nV3fDTvsU=; b=mEEpBPE/PxD0Q5Loci9VkUC4DUbEZUt869SJeHis30KYrR1r00Vl6gplR8gMRrPZg2 HE3qxH5zx5dmozUiipCQZgcyEQJhLfHDkSkBcvU0gyy/ePeVC3S/OWcsJ6cehBR6fNJx wihwprwuooW1t/ED+ttT0RMyTjpnP82n5Vep8DKMO2Xv2XIAPAgjHVQTnyfTsCGeYzcM 8aeTowYTMv5tYSOnrEkrAlFiCZlQfzn4v2mQTvORM+znB63in9kq1DYHz72+DFVZif8t MN0+KqJ4BBpWOcI+948VXnLiC3Anci4snGn+jgxj0vBvGs2+dQcCGbUiloHQS1whakAz FKEA== X-Gm-Message-State: AGRZ1gKxDQGdfyMZ8D8aLOyxkHe9NBMCv4MhKzTPnGemceZVSFvAkUb+ wQhjJFaxoE163qsI1H7XNngeH8B9ed1JOErbUP0= X-Received: by 2002:a0c:dc0f:: with SMTP id s15mr4878154qvk.40.1541196911540; Fri, 02 Nov 2018 15:15:11 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a0c:9881:0:0:0:0:0 with HTTP; Fri, 2 Nov 2018 15:15:11 -0700 (PDT) In-Reply-To: <4ebfc3aeb5335a1f671602f9a906f948c39a30da.camel@mellanox.com> References: <20181102153316.1492515-1-arnd@arndb.de> <9f214f12ec89020ceb14c1aec25b3a0d968507aa.camel@mellanox.com> <2727f37b-1742-5532-317e-3be8a984266b@gmail.com> <4ebfc3aeb5335a1f671602f9a906f948c39a30da.camel@mellanox.com> From: Arnd Bergmann Date: Fri, 2 Nov 2018 23:15:11 +0100 X-Google-Sender-Auth: 8a0crXQUdegwRGc5lDnLHjVseBw Message-ID: Subject: Re: [PATCH] net/mlx5e: fix high stack usage To: Saeed Mahameed Cc: "eric.dumazet@gmail.com" , "davem@davemloft.net" , "leon@kernel.org" , "linux-kernel@vger.kernel.org" , Moshe Shemesh , "linux-rdma@vger.kernel.org" , Boris Pismenny , Tariq Toukan , "akpm@linux-foundation.org" , Eran Ben Elisha , "netdev@vger.kernel.org" , Ilya Lesokhin , Kamal Heib 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 11/2/18, Saeed Mahameed wrote: > On Fri, 2018-11-02 at 14:39 -0700, Eric Dumazet wrote: >> >> On 11/02/2018 02:05 PM, Saeed Mahameed wrote: >> >> > temp will be mem copied to priv->stats.sw at the end, >> > memcpy(&priv->stats.sw, &s, sizeof(s)); >> > >> > one other way to solve this as suggested by Andrew, is to get rid >> > of >> > the temp var and make it point directly to priv->stats.sw >> > >> >> What about concurrency ? >> >> This temp variable is there to make sure concurrent readers of stats >> might >> not see mangle data (because another 'reader' just did a memset() and >> is doing the folding) >> >> >> mlx5e_get_stats() can definitely be run at the same time by multiple >> threads. >> > > hmm, you are right, i was thinking that mlx5e_get_Stats will trigger a > work to update stats and grab the state_lock, but for sw stats this is > not the case it is done in place. > > BTW memcpy itself is not thread safe. Before commit 6c63efe4cfab ("net/mlx5e: Remove redundant active_channels indication"), there was a read_lock() in the function apparently intended to made it thread safe. This got removed with the comment commit 6c63efe4cfabf230a8ed4b1d880249875ffdac13 Author: Eran Ben Elisha Date: Tue May 29 11:06:31 2018 +0300 net/mlx5e: Remove redundant active_channels indication Now, when all channels stats are saved regardless of the channel's state {open, closed}, we can safely remove this indication and the stats spin lock which protects it. Fixes: 76c3810bade3 ("net/mlx5e: Avoid reset netdev stats on configuration changes") I don't really understand the reasoning, but maybe we can remove the memcpy() if the code is thread safe, or we need the lock back if it's not. Arnd