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 X-Spam-Level: X-Spam-Status: No, score=-0.7 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E74FCC433B4 for ; Thu, 8 Apr 2021 16:44:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 37000610D1 for ; Thu, 8 Apr 2021 16:44:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 37000610D1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BC0AD6B0083; Thu, 8 Apr 2021 12:44:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B71456B0085; Thu, 8 Apr 2021 12:44:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9ED4E6B0087; Thu, 8 Apr 2021 12:44:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0232.hostedemail.com [216.40.44.232]) by kanga.kvack.org (Postfix) with ESMTP id 81F786B0083 for ; Thu, 8 Apr 2021 12:44:32 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 5B62518021867 for ; Thu, 8 Apr 2021 16:44:31 +0000 (UTC) X-FDA: 78009773142.13.6D5A7F2 Received: from vmicros1.altlinux.org (vmicros1.altlinux.org [194.107.17.57]) by imf28.hostedemail.com (Postfix) with ESMTP id 35CCA200025E for ; Thu, 8 Apr 2021 16:44:31 +0000 (UTC) Received: from imap.altlinux.org (imap.altlinux.org [194.107.17.38]) by vmicros1.altlinux.org (Postfix) with ESMTP id CD32E72C8B1; Thu, 8 Apr 2021 19:44:28 +0300 (MSK) Received: from example.org (ip-94-113-225-162.net.upcbroadband.cz [94.113.225.162]) by imap.altlinux.org (Postfix) with ESMTPSA id 9991E4A4726; Thu, 8 Apr 2021 19:44:27 +0300 (MSK) Date: Thu, 8 Apr 2021 18:44:26 +0200 From: Alexey Gladkov To: Linus Torvalds Cc: kernel test robot , 0day robot , LKML , lkp@lists.01.org, "Huang, Ying" , Feng Tang , zhengjun.xing@intel.com, Kernel Hardening , Linux Containers , Linux-MM , Andrew Morton , Christian Brauner , "Eric W . Biederman" , Jann Horn , Jens Axboe , Kees Cook , Oleg Nesterov Subject: Re: 08ed4efad6: stress-ng.sigsegv.ops_per_sec -41.9% regression Message-ID: <20210408164426.o5cfvv3ixowsto62@example.org> References: <7abe5ab608c61fc2363ba458bea21cf9a4a64588.1617814298.git.gladkov.alexey@gmail.com> <20210408083026.GE1696@xsang-OptiPlex-9020> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 35CCA200025E X-Stat-Signature: ho5q6mpucd4yzq65hhg8c81jompx7xkp Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf28; identity=mailfrom; envelope-from=""; helo=vmicros1.altlinux.org; client-ip=194.107.17.57 X-HE-DKIM-Result: none/none X-HE-Tag: 1617900271-733994 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Apr 08, 2021 at 09:22:40AM -0700, Linus Torvalds wrote: > On Thu, Apr 8, 2021 at 1:32 AM kernel test robot wrote: > > > > FYI, we noticed a -41.9% regression of stress-ng.sigsegv.ops_per_sec = due to commit > > 08ed4efad684 ("[PATCH v10 6/9] Reimplement RLIMIT_SIGPENDING on top o= f ucounts") >=20 > Ouch. >=20 > I *think* this test may be testing "send so many signals that it > triggers the signal queue overflow case". >=20 > And I *think* that the performance degradation may be due to lots of > unnecessary allocations, because ity looks like that commit changes > __sigqueue_alloc() to do >=20 > struct sigqueue *q =3D kmem_cache_alloc(sigqueue_cachep, flags)= ; >=20 > *before* checking the signal limit, and then if the signal limit was > exceeded, it will just be free'd instead. >=20 > The old code would check the signal count against RLIMIT_SIGPENDING > *first*, and if there were m ore pending signals then it wouldn't do > anything at all (including not incrementing that expensive atomic > count). >=20 > Also, the old code was very careful to only do the "get_user()" for > the *first* signal it added to the queue, and do the "put_user()" for > when removing the last signal. Exactly because those atomics are very > expensive. >=20 > The new code just does a lot of these atomics unconditionally. Yes and right now I'm trying to rewrite this patch. > I dunno. The profile data in there is a bit hard to read, but there's > a lot more cachee misses, and a *lot* of node crossers: >=20 > > 5961544 +190.4% 17314361 perf-stat.i.cache-misse= s > > 22107466 +119.2% 48457656 perf-stat.i.cache-refer= ences > > 163292 =C4=85 3% +4582.0% 7645410 perf-stat.i.node-l= oad-misses > > 227388 =C4=85 2% +3708.8% 8660824 perf-stat.i.node-l= oads >=20 > and (probably as a result) average instruction costs have gone up enorm= ously: >=20 > > 3.47 +66.8% 5.79 perf-stat.overall.cpi > > 22849 -65.6% 7866 perf-stat.overall.cycle= s-between-cache-misses >=20 > and it does seem to be at least partly about "put_ucounts()": >=20 > > 0.00 +4.5 4.46 perf-profile.calltrace.= cycles-pp.put_ucounts.__sigqueue_free.get_signal.arch_do_signal_or_restar= t.exit_to_user_mode_prepare >=20 > and a lot of "get_ucounts()". >=20 > But it may also be that the new "get sigpending" is just *so* much > more expensive than it used to be. Thanks for decrypting this! I spent some time to understand this report and still wasn't sure I understood it. --=20 Rgrds, legion