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 106D5EE49AF for ; Wed, 23 Aug 2023 07:33:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233372AbjHWHdY (ORCPT ); Wed, 23 Aug 2023 03:33:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232303AbjHWHdW (ORCPT ); Wed, 23 Aug 2023 03:33:22 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0118E4A; Wed, 23 Aug 2023 00:33:19 -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 93E4E221F3; Wed, 23 Aug 2023 07:33:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1692775998; 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=0SctbqgZjFFOicN/oLKPgrVMYfxZTnrl4bohndLZhFw=; b=hCXFa9a5NNinjYOciz1NJlp40rerbNvpu4j7TEmXTMQ7b/kHiHRYrRtrQdx0wxJ9Qk0XW3 TY0lUbZdY3FxijHgvhI3EJy+T4gupko+GkbciMQzNq+K3sJ3p88yJRGydrsJL5ojb26tLo +FZLVZ+yG3y6bDmDpf4RHgjJQYLrVbk= 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 77C401351F; Wed, 23 Aug 2023 07:33:18 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id bV0JGz625WTJQQAAMHmgww (envelope-from ); Wed, 23 Aug 2023 07:33:18 +0000 Date: Wed, 23 Aug 2023 09:33:17 +0200 From: Michal Hocko To: Yosry Ahmed Cc: Andrew Morton , Johannes Weiner , Roman Gushchin , Shakeel Butt , Muchun Song , Ivan Babrou , Tejun Heo , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/3] mm: memcg: use non-unified stats flushing for userspace reads Message-ID: References: <20230821205458.1764662-1-yosryahmed@google.com> <20230821205458.1764662-4-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 Tue 22-08-23 08:30:05, Yosry Ahmed wrote: > On Tue, Aug 22, 2023 at 2:06 AM Michal Hocko wrote: > > > > On Mon 21-08-23 20:54:58, Yosry Ahmed wrote: [...] > So to answer your question, I don't think a random user can really > affect the system in a significant way by constantly flushing. In > fact, in the test script (which I am now attaching, in case you're > interested), there are hundreds of threads that are reading stats of > different cgroups every 1s, and I don't see any negative effects on > in-kernel flushers in this case (reclaimers). I suspect you have missed my point. Maybe I am just misunderstanding the code but it seems to me that the lock dropping inside cgroup_rstat_flush_locked effectivelly allows unbounded number of contenders which is really dangerous when it is triggerable from the userspace. The number of spinners at a moment is always bound by the number CPUs but depending on timing many potential spinners might be cond_rescheded and the worst time latency to complete can be really high. Makes more sense? -- Michal Hocko SUSE Labs