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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 398B3CA0EC7 for ; Mon, 11 Sep 2023 22:22:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359646AbjIKWSQ (ORCPT ); Mon, 11 Sep 2023 18:18:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244198AbjIKTeX (ORCPT ); Mon, 11 Sep 2023 15:34:23 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20B5E18D; Mon, 11 Sep 2023 12:34:17 -0700 (PDT) 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-out1.suse.de (Postfix) with ESMTPS id CD7372183F; Mon, 11 Sep 2023 19:34:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1694460855; h=from:from:reply-to: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=+GtgT2X4Lzwli3PQHVCNnWgiwe9JIqA+mySpJCTGonc=; b=inBeglmLIoSjZlhjij03px88WQrURLaG1YUEBgOpUyL20GxHeUP/Y88emsAQxatOusOYl+ +Tbfps3gPaKBPyOLqvX5fZmSfkSJwTiVn9WprQ33JRTjhOvRWpHllAJj08kGrvRbfkrbJZ x2TW/UzxIda62LHY7iSw1knKIKhwACg= 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 AA837139CC; Mon, 11 Sep 2023 19:34:15 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id c4qoJrdr/2QdXQAAMHmgww (envelope-from ); Mon, 11 Sep 2023 19:34:15 +0000 Date: Mon, 11 Sep 2023 21:34:14 +0200 From: Michal Hocko To: Wei Xu Cc: Yosry Ahmed , Andrew Morton , Johannes Weiner , Roman Gushchin , Shakeel Butt , Muchun Song , Ivan Babrou , Tejun Heo , Michal =?iso-8859-1?Q?Koutn=FD?= , Waiman Long , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Thelen Subject: Re: [PATCH v4 4/4] mm: memcg: use non-unified stats flushing for userspace reads Message-ID: References: <20230831165611.2610118-1-yosryahmed@google.com> <20230831165611.2610118-5-yosryahmed@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 11-09-23 12:15:24, Wei Xu wrote: > On Mon, Sep 11, 2023 at 6:11 AM Michal Hocko wrote: > > > > On Thu 07-09-23 17:52:12, Wei Xu wrote: > > [...] > > > I tested this patch on a machine with 384 CPUs using a microbenchmark > > > that spawns 10K threads, each reading its memory.stat every 100 > > > milliseconds. > > > > This is rather extreme case but I wouldn't call it utterly insane > > though. > > > > > Most of memory.stat reads take 5ms-10ms in kernel, with > > > ~5% reads even exceeding 1 second. > > > > Just curious, what would numbers look like if the mutex is removed and > > those threads would be condending on the existing spinlock with lock > > dropping in place and removed. Would you be willing to give it a shot? > > Without the mutex and with the spinlock only, the common read latency > of memory.stat is still 5ms-10ms in kernel. There are very few reads > (<0.003%) going above 10ms and none more than 1 second. Is this with the existing spinlock dropping and same 10k potentially contending readers? -- Michal Hocko SUSE Labs