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 34BA1C3DA59 for ; Wed, 17 Jul 2024 03:00:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A4BC16B009C; Tue, 16 Jul 2024 23:00:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9FC5A6B009E; Tue, 16 Jul 2024 23:00:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8C3BA6B009F; Tue, 16 Jul 2024 23:00:51 -0400 (EDT) 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 6C9586B009C for ; Tue, 16 Jul 2024 23:00:51 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id D4BA612071A for ; Wed, 17 Jul 2024 03:00:50 +0000 (UTC) X-FDA: 82347742260.21.30F5A91 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf19.hostedemail.com (Postfix) with ESMTP id EE7B31A0021 for ; Wed, 17 Jul 2024 03:00:48 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=gsKBFyUS; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf19.hostedemail.com: domain of longman@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=longman@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721185217; a=rsa-sha256; cv=none; b=MaVTsPzmMMQ8a3Hh02ZD8MljUVagpxWxqDPh2G+EyEfUBpXqzDl0KId5vEvexNd9/5stKV JgowjihjWLP1j6xDEOZs2Db0E6cSAWib8GhmOn16+aUJnAh1os2KhiG8dITKcofr2Dl+aH 5LY/+1oHq02fdhdTJHYpyKon0/SSK0I= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=gsKBFyUS; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf19.hostedemail.com: domain of longman@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=longman@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721185217; 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=azJ33/H5zwxD3RGrWtXQAc8hehxfq2WWZbzzVI9AlkM=; b=Fjn9lC06F7QqnBrA+f7kQ9n1PmxQL5OrEgc8AAwtshaA8Id8Q35PfGPeyLMZ3pCes3UsHu m0eHnqHakux2J4sDmOOjk0Rkk1ZmWeU2AQxVZcAGfOzSjN1J/k4FavhvzXdcx28LAIDNiU zHitmZpY87FWC+G+SSe46VuDKulEHHc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721185248; h=from:from: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; bh=azJ33/H5zwxD3RGrWtXQAc8hehxfq2WWZbzzVI9AlkM=; b=gsKBFyUS0wDGrP+7T8YM0FjeKJ5dZ68vh2Fyr8sNisP1gUNVCIbEgNlzTpyUcit2nOfBiN gytFErXKCkdo+KhnZp1tHEK+FjFf50hrZ5pIztYqDycJp2mabd69HrwndNU+nYqX/HfArJ y0OczhUmwN4KBjzzYfGJPi1GGTO1HhE= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-209-MA57ON2wMPuVgbDFGpzJqA-1; Tue, 16 Jul 2024 23:00:44 -0400 X-MC-Unique: MA57ON2wMPuVgbDFGpzJqA-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 26CCF1956095; Wed, 17 Jul 2024 03:00:42 +0000 (UTC) Received: from [10.22.32.24] (unknown [10.22.32.24]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7AA231955F40; Wed, 17 Jul 2024 03:00:39 +0000 (UTC) Message-ID: <623e62c5-3045-4dca-9f2c-ed15b8d3bad8@redhat.com> Date: Tue, 16 Jul 2024 23:00:38 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH V7 1/2] cgroup/rstat: Avoid thundering herd problem by kswapd across NUMA nodes To: Yosry Ahmed , Jesper Dangaard Brouer Cc: tj@kernel.org, cgroups@vger.kernel.org, shakeel.butt@linux.dev, hannes@cmpxchg.org, lizefan.x@bytedance.com, kernel-team@cloudflare.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <172070450139.2992819.13210624094367257881.stgit@firesoul> Content-Language: en-US From: Waiman Long In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: EE7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Bqac5A6rBXlK7A06f39E3BrkismOToyffiIQ1RnvE57FmpgFy9IT+aULxAtianKpBSEr0Nkcbi7aIMM2WNdBVSWuUgq4bUkLC6bPTklGPxN0HIxGZlScAh//cW2+DpwSzOMNCjrb8IP4netDHE1jILhr9n/U1FtTe0phGBnGymm1nZEB1yBCUylaZyBnqleEy1Z/3lBr50328gdBxs40uw+3jnK75bRp4Rqu0IumWx42IUVo9r8Lri1mbPF X-Bogosity: Ham, tests=bogofilter, spamicity=0.000516, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 7/16/24 20:35, Yosry Ahmed wrote: > [..] >> >> This is a clean (meaning no cadvisor interference) example of kswapd >> starting simultaniously on many NUMA nodes, that in 27 out of 98 cases >> hit the race (which is handled in V6 and V7). >> >> The BPF "cnt" maps are getting cleared every second, so this >> approximates per sec numbers. This patch reduce pressure on the lock, >> but we are still seeing (kfunc:vmlinux:cgroup_rstat_flush_locked) full >> flushes approx 37 per sec (every 27 ms). On the positive side >> ongoing_flusher mitigation stopped 98 per sec of these. >> >> In this clean kswapd case the patch removes the lock contention issue >> for kswapd. The lock_contended cases 27 seems to be all related to >> handled_race cases 27. >> >> The remaning high flush rate should also be addressed, and we should >> also work on aproaches to limit this like my ealier proposal[1]. > I honestly don't think a high number of flushes is a problem on its > own as long as we are not spending too much time flushing, especially > when we have magnitude-based thresholding so we know there is > something to flush (although it may not be relevant to what we are > doing). > > If we keep observing a lot of lock contention, one thing that I > thought about is to have a variant of spin_lock with a timeout. This > limits the flushing latency, instead of limiting the number of flushes > (which I believe is the wrong metric to optimize). Except for semaphore, none of our locking primitives allow for a timeout parameter. For sleeping locks, I don't think it is hard to add variants with timeout parameter, but not the spinning locks. Cheers, Longman