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 2BF7DE7717D for ; Wed, 11 Dec 2024 12:27:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9F8328D0015; Wed, 11 Dec 2024 07:27:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9A83D8D0013; Wed, 11 Dec 2024 07:27:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 848D08D0015; Wed, 11 Dec 2024 07:27:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 6533C8D0013 for ; Wed, 11 Dec 2024 07:27:54 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id E0505A0E6D for ; Wed, 11 Dec 2024 12:27:31 +0000 (UTC) X-FDA: 82882602852.19.957E4A0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf04.hostedemail.com (Postfix) with ESMTP id 077C340007 for ; Wed, 11 Dec 2024 12:27:04 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=bPtvTCOJ; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf04.hostedemail.com: domain of gmonaco@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=gmonaco@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733920038; a=rsa-sha256; cv=none; b=sMGoiNU8A/VNif3VdYOrIBJT0tzfGoFvbH0Wt5kv+l4JMAOXsAeRA0NWlnNeEsWGfXL7qL ne2w5LPgrZq2TSfPAQ6bTD+EY2abIFG680VC2ZPlrPV7/9vaMcNjyZ18Sw7M+kANPfnq1C chLd2IBTYxz6u6LRNLrb0ToOtgkF5mA= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=bPtvTCOJ; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf04.hostedemail.com: domain of gmonaco@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=gmonaco@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733920038; 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=d1ZyiF0PPVacR4Sm9Um7cG+VxQE6JPvFx38FzXtDVvw=; b=E4iHURBDwx8vwFyNYP+GIZJfx/3wkwezsYj0ETHPNIY0vMIdhw4Awb3HmtCM27agJzWnBr wW0wpXjTqcfAqHsy6izA4NZBDKmLnqvk30/Nb8ZjsC3lcRS7zXp0R8O8ERzg/rrBBqfF65 t+NjJ7VOnkDioC+46V4ubghSNAWmmjY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1733920048; 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:autocrypt:autocrypt; bh=d1ZyiF0PPVacR4Sm9Um7cG+VxQE6JPvFx38FzXtDVvw=; b=bPtvTCOJOciQTGLIVcu18wbM3nHLrUM18y5VlsU2/KHWZg5fvNI/JIjEgo78uhOEMLYkzF ECnhh7PC/RkqSg0/M68Aiu9+u333/ir7eSQ/bkBFdA0SRsGDP1KwYbkZQHr0L3RHTzAKjM 3vlxmTld28vrIYopoaZqG4edxyDYoG8= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-680-x-IzvnLPNoGC4HN7w4wXzw-1; Wed, 11 Dec 2024 07:27:28 -0500 X-MC-Unique: x-IzvnLPNoGC4HN7w4wXzw-1 X-Mimecast-MFC-AGG-ID: x-IzvnLPNoGC4HN7w4wXzw Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-7b6eeef7c38so52300085a.1 for ; Wed, 11 Dec 2024 04:27:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733920047; x=1734524847; h=mime-version:user-agent:content-transfer-encoding:autocrypt :references:in-reply-to:date:cc:to:from:subject:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=d1ZyiF0PPVacR4Sm9Um7cG+VxQE6JPvFx38FzXtDVvw=; b=klSq1HXyRbt+8QPaEE6G2frsUrp4oxDrIpNZaqgnTIqa0mD47gdQqEyZ87xcXcocG6 ypYSjxoBr7mQvPrMBGREy9eyWdGIFq0qn8ZCNx9WFbOMI2ruI9aQ74KmUigWxIMXw/DN W6dq0tnd50iV5iBxVWoxhq+MhHdwr04Xpw7ywt5xCrHdpGi++ZPf1eIuqgL0nGSlmwR9 vj0YO0s19Oq6l6MJepVjj/PUzhFxulXiC/ci43lQ81TezWcVUcT03ctuVELqDdP1+Euq gnKhGDvViuObKt4nRKXgpZZtPETO3ykimVSxxdMBM5Q7bm0M3vxK/Kfdc3MCVpNmepE+ r1FQ== X-Forwarded-Encrypted: i=1; AJvYcCWw94EWDj0kU2PWp7AOwjvAGoUbcL3UO4Z5yzKDVIpJHMjK0FM2c8EEVWWdY7tk7KXsPmA/vx6XhA==@kvack.org X-Gm-Message-State: AOJu0YwRRvrNynSOUBG8G7YN5nrQLk6ALD+wvQL6H/F7OPidUFv2wwvw kQExlvIK8PRItmU6HMYL1LzFUqNUjSTOW4Nyv2h/rkH5xyXzAoPr3fa3FPTi/LYm/582OfoaUhj Yazlq037lIzZYzVN3VS05Pk0RDwPQz08NbmIaUWOsr1FCsZDG X-Gm-Gg: ASbGncuhqhqh409mCt1kmGQOFV8W2SYwOwzK3LQrpejehsbQn3iziDrz85dCnJ4fLlp xk2rataM0c7XkfgzkX6d+K+fg3Lhbymo6iEWykILHCpzS4WQ2NAXpeAbsFaWoBXDU4t2HM/zZSK I3CTikySWT6sv+GsnbxqmhIVup49dJ2LwAZZnuzqEk9RnkXzAIedG+o1N93iKc7JasHGhwwTLgR Ea+TopWQu6rBIOjjE4uBY14gyLGlQF/e4Bq9v5JoKOj198b810cQ+NA5W6Rv3g5pi6vZriWqdxV byGw X-Received: by 2002:a05:620a:370d:b0:7a9:b9dc:1b72 with SMTP id af79cd13be357-7b6eb4d6197mr382170885a.23.1733920047386; Wed, 11 Dec 2024 04:27:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IFjDXzoWUkjZKCbFFDGo21KMUbmeYO/q6FEaI+b/L0BtGt/P1Ln3jR27IYeeyUpSvh9EWg1kw== X-Received: by 2002:a05:620a:370d:b0:7a9:b9dc:1b72 with SMTP id af79cd13be357-7b6eb4d6197mr382166685a.23.1733920046971; Wed, 11 Dec 2024 04:27:26 -0800 (PST) Received: from gmonaco-thinkpadt14gen3.rmtit.csb ([185.107.56.30]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7b6b5a5c5f1sm629735185a.44.2024.12.11.04.27.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 04:27:26 -0800 (PST) Message-ID: <7c4d0c6800a4bd7a5cf4928e28d59fb469c944b9.camel@redhat.com> Subject: Re: [PATCH] sched: Move task_mm_cid_work to mm delayed work From: Gabriele Monaco To: Mathieu Desnoyers , Ingo Molnar , Peter Zijlstra , Andrew Morton , Mel Gorman , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Juri Lelli , Vincent Guittot Date: Wed, 11 Dec 2024 13:27:22 +0100 In-Reply-To: <1f4a8928-8450-48e2-bf40-e75967240d79@efficios.com> References: <20241205083110.180134-2-gmonaco@redhat.com> <4c067b75e06aadd34eff5b60fc7c59967aa30809.camel@redhat.com> <5ba975e2-06b9-4b98-bece-d601b19a06db@efficios.com> <445b4203-940d-4817-bd45-9da757f22450@efficios.com> <481a7b7716cf4eb2d592b08558d297d343d9aa25.camel@redhat.com> <1f4a8928-8450-48e2-bf40-e75967240d79@efficios.com> Autocrypt: addr=gmonaco@redhat.com; prefer-encrypt=mutual; keydata=mDMEZuK5YxYJKwYBBAHaRw8BAQdAmJ3dM9Sz6/Hodu33Qrf8QH2bNeNbOikqYtxWFLVm0 1a0JEdhYnJpZWxlIE1vbmFjbyA8Z21vbmFjb0ByZWRoYXQuY29tPoiZBBMWCgBBFiEEysoR+AuB3R Zwp6j270psSVh4TfIFAmbiuWMCGwMFCQWjmoAFCwkIBwICIgIGFQoJCAsCBBYCAwECHgcCF4AACgk Q70psSVh4TfJzZgD/TXjnqCyqaZH/Y2w+YVbvm93WX2eqBqiVZ6VEjTuGNs8A/iPrKbzdWC7AicnK xyhmqeUWOzFx5P43S1E1dhsrLWgP User-Agent: Evolution 3.54.2 (3.54.2-1.fc41) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: XT21PyR4RItfFeAhf54L3GjzgDocm0htr54E7cD20f8_1733920047 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 077C340007 X-Stat-Signature: bqz4n5fuk9d3hykjxic98r8fwzzjn3gx X-HE-Tag: 1733920024-487832 X-HE-Meta: U2FsdGVkX1/T560VVK9XtAcInEaviVpmG3Y6jdHVhJiAUVcVS9MjGMt/YxzUxlSI55KpT/lVLRGu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NovinvwZ6iOPoZvzJeifBZqal57C/CBk/WR8dYj2IiaSAClVEk0zNwCRi6fAZPZ0vzGWIhKzFMZPMy3RhepiWeSU3br3r9ZB0N+10dz2OZzIiyJNgXYiad3zf57eEu/w/zHlucZGMxqpnWJxoEohnfpz6N1ZLkTI+1MmDJvdr/IZmfAhh3oIyllXwslqYPHjiAOi+X14lCT2Xbm+iMMuWdfwPWSTLTnzFcZ X-Bogosity: Ham, tests=bogofilter, spamicity=0.011662, 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 Mon, 2024-12-09 at 10:48 -0500, Mathieu Desnoyers wrote: > On 2024-12-09 10:33, Mathieu Desnoyers wrote: > > A small tweak on your proposed approach: in phase 1, get each > > thread > > to publish which mm_cid they observe, and select one thread which > > has observed mm_cid > 1 (possibly the largest mm_cid) as the thread > > that will keep running in phase 2 (in addition to the main thread). > >=20 > > All threads other than the main thread and that selected thread > > exit > > and are joined before phase 2. > >=20 > > So you end up in phase 2 with: > >=20 > > - main (observed any mm_cid) > > - selected thread (observed mm_cid > 1, possibly largest) > >=20 > > Then after a while, the selected thread should observe a > > mm_cid <=3D 1. > >=20 > > This test should be skipped if there are less than 3 CPUs in > > allowed cpumask (sched_getaffinity). >=20 > Even better: >=20 > For a sched_getaffinity with N cpus: >=20 > - If N =3D=3D 1 -> skip (we cannot validate anything) >=20 > Phase 1: create N - 1 pthreads, each pinned to a CPU. main thread > also pinned to a cpu. >=20 > Publish the mm_cids observed by each thread, including main thread. >=20 > Select a new leader for phase 2: a thread which has observed nonzero > mm_cid. Each other thread including possibly main thread issue > pthread_exit, and the new leader does pthread join on each other. >=20 > Then check that the new leader eventually observe mm_cid =3D=3D 0. >=20 > And it works with an allowed cpu mask that has only 2 cpus. Sounds even neater, thanks for the tips, I'll try this last one out! Coming back to the implementation, I have been trying to validate my approach with this test, wrapped my head around it, and found out that the test can't actually pass on the latest upstream. When an mm_cid is lazy dropped to compact the mask, it is again re- assigned while switching in. The the change introduced in "sched: Improve cache locality of RSEQ concurrency IDs for intermittent workloads" adds a recent_cid and it seems that is never unset during the test (nothing migrates). Now, I'm still running my first version of the test, so I have a thread running on CPU0 with mm_cid=3D0 and another running on CPU127 with mm_cid, say, 127 (weight=3D2). In practice, the test is expecting 127 to be dropped (>2) but this is not the case since 127 could exhibit better cache locality, so it is selected on the next round. Here's where I'm in doubt, is a compact map more desirable than reusing the same mm_cids for cache locality? If not, should we perhaps ignore the recent_cid if it's larger than the map weight? It seems the only way the recent_cid is unset is with migrations, but I'm not sure if forcing one would make the test vain as the cid could be dropped outside of task_mm_cid_work. What do you think? Thanks, Gabriele