Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp1294262rdh; Fri, 27 Oct 2023 09:50:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGPnbx6GgPSVu24ZxW6ZMK3Ip4/K8XTQTmG8/LHV6cRO8apGBtsPMjfXma8agawikzPFZyj X-Received: by 2002:a25:f828:0:b0:d9a:3d72:bfab with SMTP id u40-20020a25f828000000b00d9a3d72bfabmr3065214ybd.40.1698425400981; Fri, 27 Oct 2023 09:50:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698425400; cv=none; d=google.com; s=arc-20160816; b=Yk1d4sZ+Ekz9rDEeSc6X1Yg5AAxB3AzbHr/zL9cpXtIIyhDAkXXd3PrSUud3d0K0kv IcVfP2Ib9OPB0tLSMh+5twMjR9/D4Kx+ippOGpB06BUkBo5U8U2xG/BZIzBK3/txcMsW LJEndf4cqgL+WFd1rGEIXRdoDZWOEXHle84e7pBU43Kk2zyCuIxe6/HjWB4bn+tYBduN /EgP/cEkrCPwix060xPB8wXZwPO5z+9S5wbUqovduqpEvdCj2X2yFxR5b+gQsToMld/v fbsGp3Ud3Wd6PDmApjPPQGUme+4B4zaZmhANaT8uPTQh9V5loMlGgbPDVpzKOz506yVF OZ7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=WALRrWciQzWK/SZFj95QwPubKh2he0JtQ0OZ6nWqRY8=; fh=SfvE4YKxHarc+4mYRLQvWrf/g5l7JvlvohgguvJ6moM=; b=C7+PEPdkrGovbfkdcHruqhs+s+Xcmr8YpQt0xkWbFFpABj0FWXhKsM9or1qrv2uBNP knzirs9aYrF0ejYVQuvAYD+rA73Ym6JtMScIrZnbDbeqMbMR98MxNFvcRpwPUHWKjfBv WqQh0/E7Z40PgWLoLpQ6HgMsp8IYRJDdEU6M3NkKap7u6I0DPCtZhsCCCfbaamjHm2Oe Oi6PjgbTQfgY2hr4Df8w4qQ2mEEIiXmf9zRX/KyMSKg4CcnuRUlnnSZ6sKfWR8n5kVvr Gp07mbxVPOxmWAfApqnt+wx/TE4H81yO1sCCA92kivOK7uUxBSlN6bF6wommvY3++wSR ON5g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id t94-20020a25aae7000000b00da086e8ae82si3592868ybi.484.2023.10.27.09.49.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 09:50:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 0244A83459EE; Fri, 27 Oct 2023 09:49:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344276AbjJ0Qtl (ORCPT + 99 others); Fri, 27 Oct 2023 12:49:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231974AbjJ0Qtj (ORCPT ); Fri, 27 Oct 2023 12:49:39 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99EC01A5 for ; Fri, 27 Oct 2023 09:49:37 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DA1BC433C8; Fri, 27 Oct 2023 16:49:33 +0000 (UTC) Date: Fri, 27 Oct 2023 12:49:30 -0400 From: Steven Rostedt To: Mathieu Desnoyers Cc: Linus Torvalds , Peter Zijlstra , LKML , Thomas Gleixner , Ankur Arora , linux-mm@kvack.org, x86@kernel.org, akpm@linux-foundation.org, luto@kernel.org, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, mingo@redhat.com, juri.lelli@redhat.com, vincent.guittot@linaro.org, willy@infradead.org, mgorman@suse.de, jon.grimm@amd.com, bharata@amd.com, raghavendra.kt@amd.com, boris.ostrovsky@oracle.com, konrad.wilk@oracle.com, jgross@suse.com, andrew.cooper3@citrix.com, Joel Fernandes , Youssef Esmat , Vineeth Pillai , Suleiman Souhlal , Ingo Molnar , Daniel Bristot de Oliveira Subject: Re: [POC][RFC][PATCH v2] sched: Extended Scheduler Time Slice Message-ID: <20231027124930.3753cdd4@gandalf.local.home> In-Reply-To: References: <20231025235413.597287e1@gandalf.local.home> <20231026105944.GJ33965@noisy.programming.kicks-ass.net> <20231026071413.4ed47b0e@gandalf.local.home> <7871472b-a0c4-4475-9671-69a3244f956d@efficios.com> <20231026164549.14d45c60@gandalf.local.home> <644da047-2f7a-4d55-a339-f2dc28d2c852@efficios.com> <20231027122442.5c76dd62@gandalf.local.home> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 27 Oct 2023 09:49:53 -0700 (PDT) On Fri, 27 Oct 2023 12:35:56 -0400 Mathieu Desnoyers wrote: > > Does that make more sense? > > Not really. > > Please see my other email about the need for a reference count here, for > nested locks use-cases. Note, my original implementation of nested locking was done completely in user space. int __thread lock_cnt; extend() { if (lock_cnt++) return; ... } unextend() { if (--lock_cnt) return; ... } > > By "atomic" operation I suspect you only mean "single instruction" which can > alter the state of the field and keep its prior content in a register, not a > lock-prefixed atomic operation, right ? Correct. Just a per cpu atomic. Hence a "andb" instruction, or the "subl", or whatever. > > The only reason why you have this asm trickiness is because both states > are placed into different bits from the same word, which is just an > optimization. You could achieve the same much more simply by splitting > this state in two different words, e.g.: > > extend() { > WRITE_ONCE(__rseq_abi->cr_nest, __rseq_abi->cr_nest + 1); > barrier() > } > > unextend() { > barrier() > WRITE_ONCE(__rseq_abi->cr_nest, __rseq_abi->cr_nest - 1); > if (READ_ONCE(__rseq_abi->must_yield)) { > WRITE_ONCE(__rseq_abi->must_yield, 0); > sched_yield(); > } > } > > Or am I missing something ? I mentioned about placing this in different bytes, although I meant words, but yeah, if we make them separate it would make it easier. But me being frugal about memory, If this was just two bits (or even a counter with an extra bit) I didn't think about wasting two words for what can be done with one. But this is still an implementation detail, and this code is still very much in flux, and I'm not as worried about those details yet. -- Steve