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 2C529C38A2D for ; Mon, 24 Oct 2022 22:30:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 248A0940008; Mon, 24 Oct 2022 18:30:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1F8BC940007; Mon, 24 Oct 2022 18:30:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E7E3940008; Mon, 24 Oct 2022 18:30:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id F378B940007 for ; Mon, 24 Oct 2022 18:30:25 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id BBA9816088B for ; Mon, 24 Oct 2022 22:30:25 +0000 (UTC) X-FDA: 80057288010.14.97F808A Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf15.hostedemail.com (Postfix) with ESMTP id 5FC3EA003E for ; Mon, 24 Oct 2022 22:30:25 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 689CB61286; Mon, 24 Oct 2022 22:30:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6ED06C433D6; Mon, 24 Oct 2022 22:30:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1666650623; bh=aV1nMMCJPYiagkx/HzsJlx2QvJo6+skgGZVrzZnzTTg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=uMzwrzeCPRV0ferTAxZsb1FzCakhmfIaNbvO7G8l65d+WsTuJqoNOaSfECukoVrBG h9C90EsD8GOcXkzh2ddKTDZCdtP0e4U5rlxfkjytJXXCX6FkXiBafdtDzmrWmIC3hr O9BszOnmVnc8qByLGbkTz0Sm+YJwZEOvsRSEdFJg= Date: Mon, 24 Oct 2022 15:30:22 -0700 From: Andrew Morton To: Shakeel Butt Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: convert mm's rss stats into percpu_counter Message-Id: <20221024153022.1b81a182eac44797b40bfda1@linux-foundation.org> In-Reply-To: <20221024052841.3291983-1-shakeelb@google.com> References: <20221024052841.3291983-1-shakeelb@google.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=uMzwrzeC; spf=pass (imf15.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666650625; a=rsa-sha256; cv=none; b=ZrhXaOhBT2jogmOtDY/eSCwtAEiV4avlxVB87ZKEakalvfaZYoqMmXf+RNwD03gQ1M76bt HpMT92HmFm9Mv98fO0ZArj8l6wmd4DMR+uieHwTIBr9QbXOfxHQyz5y5ZGGYVY1X6bVCbV lmKgesldevQCIUIyovA/fxrEGYEH93U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666650625; 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=bGwg9R40B5nIYYpHhjbrrg6C2o5wlHrhRXYY/ZhzoHM=; b=3y/syervQ/nxSM+qXF2NwvNYCsuc6Sah+GUm7vEXKLdltuOS+MoXgvmVG8jpJyuebzYDtQ kPUtFXjl2gQmOo//pjMUyfMFgHnyYl852OAXiVMmwOs4q0kH7Hs1kzgakDgw7xC9nPeaXd KKOdvp2a4l0I6RCZNQFFBiW1DAS2NiM= X-Rspamd-Queue-Id: 5FC3EA003E Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=uMzwrzeC; spf=pass (imf15.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Rspamd-Server: rspam02 X-Rspam-User: X-Stat-Signature: ydghh8cnobd8sqde5py91w3qj3duwkow X-HE-Tag: 1666650625-761768 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 Mon, 24 Oct 2022 05:28:41 +0000 Shakeel Butt wrote: > Currently mm_struct maintains rss_stats which are updated on page fault > and the unmapping codepaths. For page fault codepath the updates are > cached per thread with the batch of TASK_RSS_EVENTS_THRESH which is 64. > The reason for caching is performance for multithreaded applications > otherwise the rss_stats updates may become hotspot for such > applications. > > However this optimization comes with the cost of error margin in the rss > stats. The rss_stats for applications with large number of threads can > be very skewed. At worst the error margin is (nr_threads * 64) and we > have a lot of applications with 100s of threads, so the error margin can > be very high. Internally we had to reduce TASK_RSS_EVENTS_THRESH to 32. > > Recently we started seeing the unbounded errors for rss_stats for > specific applications which use TCP rx0cp. It seems like > vm_insert_pages() codepath does not sync rss_stats at all. > > This patch converts the rss_stats into percpu_counter to convert the > error margin from (nr_threads * 64) to approximately (nr_cpus ^ 2). Confused. The max error should be O(nr_cpus)? > However this conversion enable us to get the accurate stats for > situations where accuracy is more important than the cpu cost. Though > this patch does not make such tradeoffs. Curiousity. Can you expand on the final sentence here? > 8 files changed, 40 insertions(+), 107 deletions(-) There's that, too.