Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp7591950rwi; Mon, 24 Oct 2022 17:18:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7M/FJZnF7vcmaELpwDLxGXzgF49Ut20V0t0Y6R39NzYivVTZvGF8nXswruLpnMVkWZ5mD5 X-Received: by 2002:a17:90b:314b:b0:20d:a462:b996 with SMTP id ip11-20020a17090b314b00b0020da462b996mr41060107pjb.39.1666657133793; Mon, 24 Oct 2022 17:18:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666657133; cv=none; d=google.com; s=arc-20160816; b=sLX1B8Ka4+VDTCahwGOO2cxnXAZ3IZidJcv3x91971Ksb6rlUTPkVVdbYnhpucRFlL lQtkuIxpon9ELWi8IGQ0vTugHOIFLwsD/2OctSySc/ePCjjJBbIcIbLhBsQLVyT9+HHd NiYys1BQWJGeN138R2uPtQOL/vQ9CEm2L+/JymUtC/MmYWBV/Kjol9GQ0ZPf4y7brEt0 +jHaFzTCsLo7YD2aSjZ7HL3bHCXMyC+ae2njZoeenqsPObqgcmEYRkg909bdPttb95mE 4UIndrOLMQ97vK8PMx51vH/82tk2PTDGjZWMsP0khXokzDkcDJjnLv1vczFAEnX68i7N yjlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=bGwg9R40B5nIYYpHhjbrrg6C2o5wlHrhRXYY/ZhzoHM=; b=eE1UCfGOXB9k1S25kfVQccmdOJde1g/qmTzt3Uu225rX5suXSuBNpoPtXWvBPk3Zqh nIXwjXIdD1a7JNcIfOwFtey4/xFL7E2lYUZH473G9Q3hWae62g7iy4kXWE4AnF0/5dZM 4rrGR8xfMt0ZhEA77aGQdbRx1p7rdrjKucf8Q3ZUj0/NGS3rJo8YPDWVduKHGhrTgh1s e/2z6lZSOXiqXYxwnDeejQuSHNmBCnAgUTOuJpvBo2ULM6KgieaVAUEdcWr6FAtxnvxa HHKKO3WbbbfZYQ4Vzj6DrMR9W+Ki6csB8RTdLdPBQZHm0F4XuIogRHtFtn4z7ys/F7fK gISQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=uMzwrzeC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 66-20020a630245000000b0046effafcc4esi1039169pgc.797.2022.10.24.17.18.41; Mon, 24 Oct 2022 17:18:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=uMzwrzeC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229781AbiJYAMh (ORCPT + 99 others); Mon, 24 Oct 2022 20:12:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229681AbiJYAMQ (ORCPT ); Mon, 24 Oct 2022 20:12:16 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A53C2EFC2D for ; Mon, 24 Oct 2022 15:31:01 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id 2C1F7B810F4 for ; Mon, 24 Oct 2022 22:30:25 +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 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.