From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 490E8E95A8E for ; Mon, 9 Oct 2023 08:36:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A8C3E6B0156; Mon, 9 Oct 2023 04:36:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A3BFA6B0157; Mon, 9 Oct 2023 04:36:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 92AEE6B0158; Mon, 9 Oct 2023 04:36:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 7F6D16B0156 for ; Mon, 9 Oct 2023 04:36:55 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 41311140124 for ; Mon, 9 Oct 2023 08:36:55 +0000 (UTC) X-FDA: 81325267590.26.210EA80 Received: from out-210.mta0.migadu.com (out-210.mta0.migadu.com [91.218.175.210]) by imf11.hostedemail.com (Postfix) with ESMTP id 548B540009 for ; Mon, 9 Oct 2023 08:36:53 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=GbWjQuZI; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf11.hostedemail.com: domain of yajun.deng@linux.dev designates 91.218.175.210 as permitted sender) smtp.mailfrom=yajun.deng@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696840613; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=DrSh1nM/Lpug064dq0hv1YAXloNKtayvuIcAjhME+k0=; b=p7qo9VVLiT7Wn8duiPz5HQsxe3QRrif9C2jFp0VgfsgXTayQueaISnwy16rIlTtuzQdy7+ AduLeD+/AhBWkzdjrrBsLMiAtb6ID46B1nTM8p48wK6ufblREnWc+cgkSq1uu22Q5MwOwN 9KleRlqZHt9j9/JivQaQpBIlv+K78oQ= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=GbWjQuZI; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf11.hostedemail.com: domain of yajun.deng@linux.dev designates 91.218.175.210 as permitted sender) smtp.mailfrom=yajun.deng@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696840613; a=rsa-sha256; cv=none; b=pdAeAyzgy6t4hmKDRFd8NfIxutu3f4RLkYZTS6AuufnjIAA6bJYqGbU6KgQROVlnINkwGN Fz4q3IJzbF2/mtXkBR+0sCQZZYjRPavAa7crDslOWK2tnej1tqgyqmBFVruwrpijpai0sR y2Pbu8rTcKpL7b6D8a2ky/zTC7x7BHk= Message-ID: <296ca17d-cff0-2d19-f620-eedab004ddde@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1696840611; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DrSh1nM/Lpug064dq0hv1YAXloNKtayvuIcAjhME+k0=; b=GbWjQuZIiYqJ4jFuvhXGOHtVC+1X3aaqwG24lKNHJCR6jygYHsfImnWpOcKayGmMKSVB13 pRMmKcq4FUEMYCLfrwl1VGD1p/SWEtVHNDnS6suRlS7Un9WuQ1E3RLbuZxcqj3OxYk/J0N dWir1cILFvyNVczegMMvcD3Ajuqujc0= Date: Mon, 9 Oct 2023 16:36:42 +0800 MIME-Version: 1.0 Subject: Re: [PATCH net-next v7] net/core: Introduce netdev_core_stats_inc() Content-Language: en-US To: Eric Dumazet Cc: rostedt@goodmis.org, mhiramat@kernel.org, dennis@kernel.org, tj@kernel.org, cl@linux.com, mark.rutland@arm.com, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Alexander Lobakin , linux-trace-kernel@vger.kernel.org, linux-mm@kvack.org References: <20231007050621.1706331-1-yajun.deng@linux.dev> <917708b5-cb86-f233-e878-9233c4e6c707@linux.dev> <9f4fb613-d63f-9b86-fe92-11bf4dfb7275@linux.dev> <4a747fda-2bb9-4231-66d6-31306184eec2@linux.dev> <814b5598-5284-9558-8f56-12a6f7a67187@linux.dev> <508b33f7-3dc0-4536-21f6-4a5e7ade2b5c@linux.dev> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Yajun Deng In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: 548B540009 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: hu9cs8oomj1ju8ub7nftn4fi1sz48x1q X-HE-Tag: 1696840613-622278 X-HE-Meta: U2FsdGVkX1/sGVy2AwziBxxVucch0UXbZjxSEETi+1A0gbqBWIV8VcWI+R0UvlEY27eOQGKSuBa/UGUajItqEzoOvnInCvd0+Y5Vh39bV2ehMrVM4ptB0cwyrUR/TrIomtnpkRZGO42uRQHc7UK6UJ6oYeexFgrT6ooFQU24iU3bBn8EGQ0ld/z4OoCcW0uIIFOvpPmN3c26EZmrPMAJ0zjngXcDN19qQWPe3vhtq9erDIek0ICTPCBxyF3JEh2Z6AdixJe7N0l2NrBJ7MKbtZsiOAZPCUD7EcvFz6rZ83n9LTHjU0DyjIX0f7t2/znPSj+5A+cbxZBUveZbkQXeiq9761atcZrB4+Px8njY76gBhIRRpxY6Zz4nVWrNPLBnc8ppVaV+cLeHPd4xW6iwKef9DkDKFzHNnce5am1TLC8HvzJC8V++XUtTGGz3XMFqc9P7Tg3namAzOCY//US2UjCIzgSN4ueOyXeZDuGQWduClyGhJ3mPuA5HQy11nhANTh0LVv6PX2nWHOK1hPoYEtmfBx/FcaydTQlbn4+3UNvWTZuFkLi6TMM3EIiHa1w4nWj8b9BG2ENGRBMTCpQqHrUfdms8lr/PDAIPVnyAuk8X11IaDNjL8v6yNCl5gQZsbBxsePcbxSwK8tOl2bku1H50m9tIUSxbhy1d+NLJTJu88BIuo23hE5iT5Z+ehcZrlIwTlMOOWbByXJP/FzarJN4x2raOEB9EpCBIVpNW6w0IhD0x4MLdtdvfwhDLjVRmzOUT/ckrtT3shwQi+1uXRC0JXOtmb+1l9LCUN3D1LNBJQnc6fwvG9eoNPMA5hYlO6IiKi1V/RfuPyhpbZCHSiJDdkQzO49wTsAeVdjdRTUvZDzNxkhjOwDAPur4/Et2Fw2duOO1D8H+GnJ9r962+Dv6Opsbj5ELNtVBTJE9XqgxdkDjiSlC80HruwJJ+OgPiEQ43Msq6GztgsBWwr6n nExt6zs4 fJ2E1mLlcT1v+QjnjT0kmot+nf0BbIhYLizXGuEtvU84XehAMjbKhS9M2BiWpnCXqX3B9qUdAdwNWaKeG2oDFU1P4+OENTYM+ZlQpWmXRYf8d+F6BwwtZ65azbL+B1W7q08uXozJZqcJIDHo= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000099, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 2023/10/9 16:20, Eric Dumazet wrote: > On Mon, Oct 9, 2023 at 10:14 AM Yajun Deng wrote: >> >> On 2023/10/9 15:53, Eric Dumazet wrote: >>> On Mon, Oct 9, 2023 at 5:07 AM Yajun Deng wrote: >>> >>>> 'this_cpu_read + this_cpu_write' and 'pr_info + this_cpu_inc' will make >>>> the trace work well. >>>> >>>> They all have 'pop' instructions in them. This may be the key to making >>>> the trace work well. >>>> >>>> Hi all, >>>> >>>> I need your help on percpu and ftrace. >>>> >>> I do not think you made sure netdev_core_stats_inc() was never inlined. >>> >>> Adding more code in it is simply changing how the compiler decides to >>> inline or not. >> >> Yes, you are right. It needs to add the 'noinline' prefix. The >> disassembly code will have 'pop' >> >> instruction. >> > The function was fine, you do not need anything like push or pop. > > The only needed stuff was the call __fentry__. > > The fact that the function was inlined for some invocations was the > issue, because the trace point > is only planted in the out of line function. But somehow the following code isn't inline? They didn't need to add the 'noinline' prefix. + field = (unsigned long *)((void *)this_cpu_ptr(p) + offset); + WRITE_ONCE(*field, READ_ONCE(*field) + 1); Or + (*(unsigned long *)((void *)this_cpu_ptr(p) + offset))++;