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 72964E77173 for ; Fri, 6 Dec 2024 08:53:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0578D6B01F6; Fri, 6 Dec 2024 03:53:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0068D6B01F7; Fri, 6 Dec 2024 03:53:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE9126B01F8; Fri, 6 Dec 2024 03:53:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id BA1586B01F6 for ; Fri, 6 Dec 2024 03:53:31 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 60B70A196B for ; Fri, 6 Dec 2024 08:53:31 +0000 (UTC) X-FDA: 82863920286.16.31506D5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf16.hostedemail.com (Postfix) with ESMTP id 15C0B180005 for ; Fri, 6 Dec 2024 08:53:11 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PqLYUPUi; spf=pass (imf16.hostedemail.com: domain of gmonaco@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=gmonaco@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733475197; 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=dQsPkFZWr/tWQwTwc2UOwpKsAv2li1hhpvLNjprhWFc=; b=RtjfeXLUVRGozh7gWlHsVKENQoK3wmryNLlti9thKVFOGMiw/K9YymoYgMIeCcZWuV9zhH nA4ByOpsoDZcf0gvVxSXhy7scacgTBK9zBuxzd4VlCOeexnfjOe8S+E2WzBFtubvkE9gHT c4BWTv/VRLU7j8E5smu0/juYF9GN0ow= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PqLYUPUi; spf=pass (imf16.hostedemail.com: domain of gmonaco@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=gmonaco@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733475197; a=rsa-sha256; cv=none; b=FjjMEPa4cYb1s4V9lo/bFPfR4KOk96Vm6PCHbwrVIy+KCh+gKZR4H8JFw+E9ayzY3crlWJ 02GrBKRVK2NsCwwn1RnhGUq/8HHNKk8Mz7gQY5yaj7D7b9t+j8KxYdDBxh/CSkssweSbQk FEUVCyGl/JDUmaULw9tiXCEEgvQSTDY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1733475208; 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=dQsPkFZWr/tWQwTwc2UOwpKsAv2li1hhpvLNjprhWFc=; b=PqLYUPUizkWGmJhH0ZHPG8MNXdARXkLIJM767BQRjdV1fQ3DUnWy/sihZf9Nae/f+TMSzS OkSHrSOaWhj+d+WgHk96L0MOw9DohmbNc3oEUfOdShQjrq3XeuRO3rtIEz2lO1JeSfIJcp P4vVJvXWFl0+a+ko2906KanToosauuQ= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-684-mJfMDSAAOni03wQnpUIO_g-1; Fri, 06 Dec 2024 03:53:27 -0500 X-MC-Unique: mJfMDSAAOni03wQnpUIO_g-1 X-Mimecast-MFC-AGG-ID: mJfMDSAAOni03wQnpUIO_g Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-6d8860ab00dso31726096d6.0 for ; Fri, 06 Dec 2024 00:53:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733475207; x=1734080007; 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=dQsPkFZWr/tWQwTwc2UOwpKsAv2li1hhpvLNjprhWFc=; b=tvvrGC6a0krWq7m56UuGDHWMxiC4QmxnEIVf9XsG5R9oazWbSz1YCv6haZL+2Fk/dk cmOrtD+fksYJcZ93ILgZ41yGEAfsmlcjqSBMFQRkr8vX9DcXw81RPRJmuUUMNpFIjByx N475uPEUNBdC4bEyHzVZotYiixR1PJFfEMmcdcptLG3wC6SNNI+4LB8veDYKsK6VIoTD KWHstme5bry1J1OEociK3T5vLrEIt6S+xJ2vuGzB4lqGpT2bHTKmJmPs2ZtXQZXZTvbg Be0h2ljgssDhVBAUkbN5kUcXsSyD1EtI36kXqqAW/hnJiv/LRyR1mTNq3TqHY3hXZpUo 85qw== X-Forwarded-Encrypted: i=1; AJvYcCVoc/aySN5P5bhtsDwCUZdx9fke5cpttmXHHYGZkHRTh+zIP5uriw8HDU0YCFbg2tUaUDqwCk+SfQ==@kvack.org X-Gm-Message-State: AOJu0Yx9lpjmP8PzBeKf5U2u3G/jeQIpkJR+VWJZ3Ju7EIyowdz6TgpS YbGSdUjg902AUD1i8XbGQ99UYKKiMe4ohReZtmEO9cTE2y5RhYhi6RMh8lu7sVE+mqlSimF9j9B XMlNEQGm4zvfc0YovFgRs3LcsXAUI+i1m/ZzCei6kPX3DryEw X-Gm-Gg: ASbGnct3iaLEKmHzr7qEMk81pUBf7faydV+EQASBIwOTdQLWUEN7DcKyGZ5X/kofDzg ADNhjgaUXUdWU3+RSAaBaV5X6ehLEfw9b/cWQx4tqYbrz7DdT4kxgHM0SEuMKo86QXAabhptoQZ 8A4Ht0e466GRvZ3CYmzK5t1eV+0SPdqKXMFJbhW3mnMqANWl9zjBki/ENewjpyV8g5+G+Qe1RZ1 qy79JNUe0ZK5HUI8dk6w6c9Fgid3S50rZu+STh35WYQRBXftDKK0tYkhNcIvMvX3MQyPtWzoRRA X-Received: by 2002:a05:6214:5195:b0:6d8:9e16:d083 with SMTP id 6a1803df08f44-6d8e70d6eb2mr30193026d6.3.1733475206876; Fri, 06 Dec 2024 00:53:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IHuIt3GmOjFHzFyqi2fUZDfOlLKfiJiyAspNyaIfAL0leXUx0zN3aoJ55+2dkoSOqMA86dikg== X-Received: by 2002:a05:6214:5195:b0:6d8:9e16:d083 with SMTP id 6a1803df08f44-6d8e70d6eb2mr30192766d6.3.1733475206551; Fri, 06 Dec 2024 00:53:26 -0800 (PST) Received: from gmonaco-thinkpadt14gen3.rmtit.csb ([185.107.56.35]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6d8da66da32sm17004936d6.2.2024.12.06.00.53.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 00:53:26 -0800 (PST) Message-ID: 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: Fri, 06 Dec 2024 09:53:20 +0100 In-Reply-To: <5ba975e2-06b9-4b98-bece-d601b19a06db@efficios.com> References: <20241205083110.180134-2-gmonaco@redhat.com> <4c067b75e06aadd34eff5b60fc7c59967aa30809.camel@redhat.com> <5ba975e2-06b9-4b98-bece-d601b19a06db@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: -SDfzlFpjxycD-_feTInPnLVHWHHD0DEZDw1h7t-enQ_1733475207 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam05 X-Stat-Signature: dd6u5ybp4dmcayz9yxkz97oui4ciizmq X-Rspamd-Queue-Id: 15C0B180005 X-Rspam-User: X-HE-Tag: 1733475191-62120 X-HE-Meta: U2FsdGVkX18T60SPAjOeNVO9j9gvBnvE8ftXSrcs4DFtEkr08/Oh2rI5dT4YBFQp3kTge/kIe3oQq/NVTZf6Mo6B+Ih8tQbKLcA9v1Sa9smLJc5Ol4Adbr/TtFe0YL1XSzuGWJhiagK4xOqG+7J1mWhSIERAR6ElKV8qn595Ouu8hng61K2iex7kyMBbeboFsiz9g85jx9R2Uc9KWEOgQF/Qn55j1YgD0B6MI+lQtx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6KhCfP3+WqGUcmVlGBmXcz4VpMWw7600aoWSvTk0PwY2Yycziv4IpQaK1cCI9wOXr3v X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, 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 Thu, 2024-12-05 at 11:25 -0500, Mathieu Desnoyers wrote: > On 2024-12-05 09:33, Gabriele Monaco wrote: >=20 > > Before sending a V2, however, I'd like to get some more insights > > about > > the requirements of this function. > >=20 > > The current behaviour upstream is to call task_mm_cid_work for the > > task > > running after the scheduler tick. The function checks that we don't > > run > > too often for the same mm, but it seems possible that some process > > with > > short runtime would rarely run during the tick. > >=20 >=20 > So your concern is about a mm with threads running in short bursts, > and those would happen to rarely run while the tick interrupt is > triggered. We may indeed be missing something here, because the goal > is to ensure that we periodically do the task_mm_cid_work for each > mm. >=20 > The side-effect of missing this work is not compacting the > mm_cid allocation cpumask. It won't cause rseq to fail per se, > but it will cause the mm_cid allocation to be less compact than > it should be. Yes, that was exactly the case, tasks like timerlat/cyclictest running periodically but doing very short work. Makes sense, now it's much clearer. >=20 > > The behaviour imposed by this patch (at least the intended one) is > > to > > run the task_mm_cid_work with the configured periodicity (plus > > scheduling latency) for each active mm. >=20 > What you propose looks like a more robust design than running under > the tick. >=20 > > This behaviour seem to me more predictable, but would that even be > > required for rseq or is it just an overkill? >=20 > Your approach looks more robust, so I would be tempted to introduce > it as a fix. Is the space/runtime overhead similar between the > tick/task work approach vs yours ? I'm going to fix the implementation and come up with some runtime stats to compare the overhead of both methods. As for the space overhead, I think I can answer this question already: * The current approach uses a callback_head per thread (16 bytes) * Mine relies on a delayed work per mm (88 bytes) Tasks with 5 threads or less have lower memory footprint with the current approach. I checked quickly on some systems I have access to and I'd say my approach introduces some memory overhead on an average system, but considering a task_struct can be 7-13 kB and an mm_struct is about 1.4 kB, the overhead should be acceptable. >=20 > >=20 > > In other words, was the tick chosen out of simplicity or is there > > some > > property that has to be preserved? >=20 > Out of simplicity, and "do like what NUMA has done". But I am not > particularly attached to it. :-) >=20 > >=20 > > P.S. I run the rseq self tests on both this and the previous patch > > (both broken) and saw no failure. >=20 > That's expected, because the tests do not so much depend on the > compactness of the mm_cid allocation. They way I validated this > in the past is by creating a simple multi-threaded program that > periodically prints the current mm_cid from userspace, and > sleep for a few seconds between printing, from many threads on > a many-core system. >=20 > Then see how it reacts when run: are the mm_cid close to 0, or > are there large values of mm_cid allocated without compaction > over time ? I have not found a good way to translate this into > an automated test though. Ideas are welcome. >=20 > You can look at the librseq basic_test as a starting point. [1] Perfect, will try those! Thanks, Gabriele