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 25F3EC00A5A for ; Thu, 19 Jan 2023 12:52:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7450A6B0074; Thu, 19 Jan 2023 07:52:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6F58D6B0075; Thu, 19 Jan 2023 07:52:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5BCAD6B0078; Thu, 19 Jan 2023 07:52:20 -0500 (EST) 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 4A5566B0074 for ; Thu, 19 Jan 2023 07:52:20 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 1005FA05BF for ; Thu, 19 Jan 2023 12:52:20 +0000 (UTC) X-FDA: 80371536840.12.C8B8D27 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf19.hostedemail.com (Postfix) with ESMTP id C084E1A0010 for ; Thu, 19 Jan 2023 12:52:16 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=uHFXZnGw; spf=pass (imf19.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1674132737; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=WjnBtS+tWF2y+b/Ndk23xVEsnNoyBzklntYtG4WzfME=; b=4P8MuZDxZh1nhPORcW1nnutVMgX/b/Zd9wh33ltnAEUoNE/d3IZay1tuXBLIC7kdhHCqLh faaspGUlMt7ce6StViE01ulIhOEB1ssUbbaeP7cQ3X2+QiH4nbQ28QUfZblNbvEIsQjpdE Xg/EU1cNa1dK7kf6wh3xC+ytyjzZ+jE= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=uHFXZnGw; spf=pass (imf19.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674132737; a=rsa-sha256; cv=none; b=yYkW7/njO5AETwRMu+IYTPhuU2USd14hCEo9K/bK81Ry2jYsO2Lmdd+EYmdPdHz4TY6b1u poamyiOu98IBfCkXQZ3ZOKyZzAnCpVlNRiZ60eg5iNpSpA4lvNTgxjdsCwPU6GbqY913ni W8PC7vW4IsVkeYyYqr1swOAW1snIefs= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 144CD5CDCC; Thu, 19 Jan 2023 12:52:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1674132735; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=WjnBtS+tWF2y+b/Ndk23xVEsnNoyBzklntYtG4WzfME=; b=uHFXZnGwRsIQkOAXvNc5r12Q8Zjx2e1IZnmxixDECtV/in4b7NwxXomeAGlDi6OtCDRXDa dtvKDLvhExTrXALBacIHpSO15pgEQvgikygHOliJ8ytuR2BXMAU/cs4QzXNA9SPokcCXHP iYzdodWW/Wcksac0HQ4vT5akJUfYwkQ= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id DD37F139ED; Thu, 19 Jan 2023 12:52:14 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id v22dNf48yWPMbAAAMHmgww (envelope-from ); Thu, 19 Jan 2023 12:52:14 +0000 Date: Thu, 19 Jan 2023 13:52:14 +0100 From: Michal Hocko To: Suren Baghdasaryan Cc: paulmck@kernel.org, akpm@linux-foundation.org, michel@lespinasse.org, jglisse@google.com, vbabka@suse.cz, hannes@cmpxchg.org, mgorman@techsingularity.net, dave@stgolabs.net, willy@infradead.org, liam.howlett@oracle.com, peterz@infradead.org, ldufour@linux.ibm.com, laurent.dufour@fr.ibm.com, luto@kernel.org, songliubraving@fb.com, peterx@redhat.com, david@redhat.com, dhowells@redhat.com, hughd@google.com, bigeasy@linutronix.de, kent.overstreet@linux.dev, punit.agrawal@bytedance.com, lstoakes@gmail.com, peterjung1337@gmail.com, rientjes@google.com, axelrasmussen@google.com, joelaf@google.com, minchan@google.com, jannh@google.com, shakeelb@google.com, tatashin@google.com, edumazet@google.com, gthelen@google.com, gurua@google.com, arjunroy@google.com, soheil@google.com, hughlynch@google.com, leewalsh@google.com, posk@google.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-kernel@vger.kernel.org, kernel-team@android.com Subject: Re: [PATCH 39/41] kernel/fork: throttle call_rcu() calls in vm_area_free Message-ID: References: <20230109205336.3665937-1-surenb@google.com> <20230109205336.3665937-40-surenb@google.com> <20230118183447.GG2948950@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: C084E1A0010 X-Stat-Signature: 7yxrdt3u4ofdq55s3hzwh1oqs596ezr3 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1674132736-549704 X-HE-Meta: U2FsdGVkX19Vn4S6Ivf/4O/nEzrM7tbXa8PJSnsvSk7NOzj5IsVPY8V2mjDQNxMg++QAAKs8J66/Hp3Tz6iywOx1mi0ECCx13VYIu5bEiJRIHZ6oEKp9XUh0uu3XjxAhatJbqjLk4vvyOblCLASrkzM4OO/d4DxktUHhl4VFrmV6EooGeQcMu24cuHLa3elspCRGwR5yPk9wgGJXRI8j3sID3snHzqK962+yBR/pYuhwRyeAmzaOs0SYvCjGlcyIGTazoKRYMGibmZ0jJZnOSAlf2ezwVqczODxZArrCd0SLwWbIf1TiZOgLRIjpMRpH579T0NnXXj8WaYqBlrPjLDfJiI3BdRGb+3PV1prJV8I6F/iSzt8Q7ItNBHXnxyeYwwyFUcQ/woJsr+V4/0ZNoEWQ192856GrOk03t0JeFJz7tbfwuoo3X28+jwCo3go9bZlYKNhUDINmmvxpzhl1w1Tq8NvMWXM73saZTxi/zfUrcsiasoPG5thvh6SXQLSA9Q2kZCW1EdpiM3mlspwSpDXIwW7SJq0uwIayUFz6n13UfTKAOBBMjfSDMS5SJmubVmoisiZ+fqWCC4xSw0nMc/QkSKrjn9LdIBBA2t0bVA34vC5LDUOrA2pZxjVIOOTahNVhBli2/b5Rfqqao72YCD/rhFoN7+0kxylXAfi7L1OBfX9c0DruIYRvAuMz9YRj0bxwtqZnq/9K5tZmJOzO2bdGmSZKYM8SZDsu/RjMrqBqQLuBkPw8jLmRjylImoSsmt7aYu+DevwoPCACJZfnFdbdIWLnnLiUZFyFrDwvUR/oD4urV3kX/V8Ne4JDxKZGKsFLrrrTSLqVmml2AB6hI2RHfWUunu5NnkJQMVqRiZvyN9wRr8zW0FMGQgOQGUDfjKF4jIjTpmgTgOeXixosAjVxVzMxr+FZ 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 Wed 18-01-23 11:01:08, Suren Baghdasaryan wrote: > On Wed, Jan 18, 2023 at 10:34 AM Paul E. McKenney wrote: [...] > > There are a couple of possibilities here. > > > > First, if I am remembering correctly, the time between the call_rcu() > > and invocation of the corresponding callback was taking multiple seconds, > > but that was because the kernel was built with CONFIG_LAZY_RCU=y in > > order to save power by batching RCU work over multiple call_rcu() > > invocations. If this is causing a problem for a given call site, the > > shiny new call_rcu_hurry() can be used instead. Doing this gets back > > to the old-school non-laziness, but can of course consume more power. > > That would not be the case because CONFIG_LAZY_RCU was not an option > at the time I was profiling this issue. > Laxy RCU would be a great option to replace this patch but > unfortunately it's not the default behavior, so I would still have to > implement this batching in case lazy RCU is not enabled. > > > > > Second, there is a much shorter one-jiffy delay between the call_rcu() > > and the invocation of the corresponding callback in kernels built with > > either CONFIG_NO_HZ_FULL=y (but only on CPUs mentioned in the nohz_full > > or rcu_nocbs kernel boot parameters) or CONFIG_RCU_NOCB_CPU=y (but only > > on CPUs mentioned in the rcu_nocbs kernel boot parameters). The purpose > > of this delay is to avoid lock contention, and so this delay is incurred > > only on CPUs that are queuing callbacks at a rate exceeding 16K/second. > > This is reduced to a per-jiffy limit, so on a HZ=1000 system, a CPU > > invoking call_rcu() at least 16 times within a given jiffy will incur > > the added delay. The reason for this delay is the use of a separate > > ->nocb_bypass list. As Suren says, this bypass list is used to reduce > > lock contention on the main ->cblist. This is not needed in old-school > > kernels built without either CONFIG_NO_HZ_FULL=y or CONFIG_RCU_NOCB_CPU=y > > (including most datacenter kernels) because in that case the callbacks > > enqueued by call_rcu() are touched only by the corresponding CPU, so > > that there is no need for locks. > > I believe this is the reason in my profiled case. > > > > > Third, if you are instead seeing multiple milliseconds of CPU consumed by > > call_rcu() in the common case (for example, without the aid of interrupts, > > NMIs, or SMIs), please do let me know. That sounds to me like a bug. > > I don't think I've seen such a case. > Thanks for clarifications, Paul! Thanks for the explanation Paul. I have to say this has caught me as a surprise. There are just not enough details about the benchmark to understand what is going on but I find it rather surprising that call_rcu can induce a higher overhead than the actual kmem_cache_free which is the callback. My naive understanding has been that call_rcu is really fast way to defer the execution to the RCU safe context to do the final cleanup. -- Michal Hocko SUSE Labs