Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp61489lqb; Tue, 16 Apr 2024 08:50:45 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUc/F/E4ftIVwnKwScHPvvmSnkF0KSE1qkRBD6Jgk8/eB7Be/elXuDcoYcY1EpiNroV5/kH9+Es6Ze6vYm54VOrHuL36ggT5pTU58n6kQ== X-Google-Smtp-Source: AGHT+IF8E5eFRO49q6j4UkqAgzBMMutNihh+sw4310Qm+coJl1OvL3zlIBYr5eGVIlPFeem3U01J X-Received: by 2002:a05:620a:d53:b0:78e:c9b4:de01 with SMTP id o19-20020a05620a0d5300b0078ec9b4de01mr13158747qkl.13.1713282644836; Tue, 16 Apr 2024 08:50:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713282644; cv=pass; d=google.com; s=arc-20160816; b=Gxt6BElgZHfhNlbe8a/1iEhLIL/vqNywyWCsqzySryaiD3MP1GUCTcQ8N04Sp4rteA PQtugUc8pimD/Chm/ooC4Wd/40LAvyQMTkGjXbOUBA/zfKeucPuylKeQXiYQ+hAudchF 5sjWTGro//r9MyzuCTaXvzbFSvm2FCqrVcXQZaaTBZP+DsOIfbGrB89lscaRCO3l+r0M pm/2+7t1cJ6N1UbuvhwrzVOGYuQK78zr6qQ6KGa2k0oLxe5s+f1vUHz+sUlxvD6lTYMt DooM4RwX4OguSsDc+c5521sA+i0+NkegmiSyJ8A3T9i5979TB5itcCd3lL/dL04SnbVb UNPQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=wVWhOXvGG+yObUBTl7o/q7ZThNzkFqz22v3LgF9rG04=; fh=/7AqYDe4mQKoJZ8Roi+FJPgiYc3Gyu8g/sTN1gbnCOE=; b=T3ZRgnItDLwkVqWxKsBLflTW7NwfKznUlEsa2W1clZ2JxmCdIkkz/aU1OnBNzH3hq/ RlHrUdvAAPn9dAvOHvIaYQ2v0TOCpSEJFqlFFV12KiDpmz5Zw6roPJQtHmzov3/25dvS ky4J/85I7uVLWaYyGiya+5s4aBdjthRqDWAmQfWkLVlinWaL/jG/NGmBb4WSsYSalZhe uO7tRgpiGJp1/dCkvNsPYuwW4/4rwnTFHKydwh31yTLLEnuI5C9kuQWrHI6m5RsazDtW ygQto+BOfarREnXMrNZUlyv7Rxwledodrw81OYSpWMSR/JL9YEHb6oyEXEUYRJ8wzuJj 4qSg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=hiIgWI9h; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-147154-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147154-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d6-20020a05620a204600b0078edc57fa88si7111040qka.216.2024.04.16.08.50.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 08:50:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-147154-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=hiIgWI9h; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-147154-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147154-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 8F52E1C2132F for ; Tue, 16 Apr 2024 15:50:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9DE7A131758; Tue, 16 Apr 2024 15:50:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="hiIgWI9h" Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6AFD41311B5; Tue, 16 Apr 2024 15:50:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.92.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713282626; cv=none; b=EgeH8Ephu6vQHfSVuknxjSnu10FSSuZvMO0cBsRbqD5irNbMbM/RMI05hXAE/OOz+ysoViVSJIDMWayRLXC+5HjoowX9f2lYNdLRBpr7m/VogTXS7P/QNkchsgzbzpH6lsMujKSBbOueMEE3zzL/QziWNCenX6pNmPTeC8Cz4sg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713282626; c=relaxed/simple; bh=3Y9O0MlxyrAJ2pHeJl4SB/ssSLif36xZUfaHCTP0w1s=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=QAQstXZ12wgZ6kktvHBjSUKEr9nj2EuBOczxYM8nmp5B8ctNEze7/ulQMl8Otwp/ygrwvWi69pRj5T+Be1EW/M+vZWiMHbsbuLf5QipsVA8CITZfWsMfPAV+zgEPBI1i3socTNncO1LcoU4oEjt514btB1yjCodKPk1yLmNkM7E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=hiIgWI9h; arc=none smtp.client-ip=90.155.92.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=wVWhOXvGG+yObUBTl7o/q7ZThNzkFqz22v3LgF9rG04=; b=hiIgWI9hsxFGLq9jXQ9mjcpQd2 UF1ybZKNzoUandzUz0yQWqJF0SjY+Wfs5LZ0z7dHeTt6ymH2hhcHROmAanmEC2gC3PxMvh75VWdtl yo63GebQ3mzj3xr35c8S+qzrbaSj0pVQ3ifm6BGkwriazxon0AJWY4bldKRhkRDpgsCE3BWweL016 JTsHWwEwEV83R8ulEYAdETg5EMr6ZQXg4HaAKqlGElSpCw7mO2mG9HlzqX2uMuad4l2d0P85H+jpG peIeh102/pwL/zAZRjIefAw25/4hZd+QhYOrVGN2F4gHWbtiF5m6xoLC6yXTYHlAxLMJy98N1ijo8 3tOXdM4Q==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwl4Y-0000000B8Vt-416A; Tue, 16 Apr 2024 15:50:15 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 812F530040C; Tue, 16 Apr 2024 17:50:14 +0200 (CEST) Date: Tue, 16 Apr 2024 17:50:14 +0200 From: Peter Zijlstra To: Elizabeth Figura Cc: Arnd Bergmann , Greg Kroah-Hartman , Jonathan Corbet , Shuah Khan , linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, wine-devel@winehq.org, =?iso-8859-1?Q?Andr=E9?= Almeida , Wolfram Sang , Arkadiusz Hiler , Andy Lutomirski , linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Randy Dunlap , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng Subject: Re: [PATCH v4 00/30] NT synchronization primitive driver Message-ID: <20240416155014.GB12673@noisy.programming.kicks-ass.net> References: <20240416010837.333694-1-zfigura@codeweavers.com> <20240416081421.GB31647@noisy.programming.kicks-ass.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240416081421.GB31647@noisy.programming.kicks-ass.net> On Tue, Apr 16, 2024 at 10:14:21AM +0200, Peter Zijlstra wrote: > > Some aspects of the implementation may deserve particular comment: > > > > * In the interest of performance, each object is governed only by a single > > spinlock. However, NTSYNC_IOC_WAIT_ALL requires that the state of multiple > > objects be changed as a single atomic operation. In order to achieve this, we > > first take a device-wide lock ("wait_all_lock") any time we are going to lock > > more than one object at a time. > > > > The maximum number of objects that can be used in a vectored wait, and > > therefore the maximum that can be locked simultaneously, is 64. This number is > > NT's own limit. AFAICT: spin_lock(&dev->wait_all_lock); list_for_each_entry(entry, &obj->all_waiters, node) for (i=0; ientries[i].obj->lock, &dev->wait_all_lock); Where @count <= NTSYNC_MAX_WAIT_COUNT. So while this nests at most 65 spinlocks, there is no actual bound on the amount of nested lock sections in total. That is, all_waiters list can be grown without limits. Can we pretty please make wait_all_lock a mutex ? > > The acquisition of multiple spinlocks will degrade performance. This is a > > conscious choice, however. Wait-for-all is known to be a very rare operation > > in practice, especially with counts that approach the maximum, and it is the > > intent of the ntsync driver to optimize wait-for-any at the expense of > > wait-for-all as much as possible. Typical sane usage is a good guide for performance, but you must not forget about malicious userspace and what they can do on purpose to mess you up. Anyway, let me stare more at all this....