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 756BCC0218A for ; Sat, 1 Feb 2025 21:51:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B6F0B6B007B; Sat, 1 Feb 2025 16:51:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AF5EB6B0083; Sat, 1 Feb 2025 16:51:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9480D6B0085; Sat, 1 Feb 2025 16:51:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 70BAD6B007B for ; Sat, 1 Feb 2025 16:51:12 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id ECFC21A01E9 for ; Sat, 1 Feb 2025 21:51:11 +0000 (UTC) X-FDA: 83072721942.23.5EFC7AD Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) by imf14.hostedemail.com (Postfix) with ESMTP id 03F2210000F for ; Sat, 1 Feb 2025 21:51:09 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="WMHxX/Gh"; spf=pass (imf14.hostedemail.com: domain of david.laight.linux@gmail.com designates 209.85.221.52 as permitted sender) smtp.mailfrom=david.laight.linux@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1738446670; 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=y6+6LjaugE0DyQnf73qvCDL5j+VRZNBEK4vkemWJG2c=; b=1LUlZ2mAQ8myyBXX8YQCH7AptWyGPOSSmGTTls5Y+fii3GSxAERn0mOxwH7HLtgE4WVDIo 55dir3lGnY8fGOi9iOHrOHtXiPAKCVMgJKRgVkn8awIuHW+II3X8u23g/SBtwLBAVnV+62 cUtWa4yemVWZyKQ86YrpXv8cBEA3ADw= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="WMHxX/Gh"; spf=pass (imf14.hostedemail.com: domain of david.laight.linux@gmail.com designates 209.85.221.52 as permitted sender) smtp.mailfrom=david.laight.linux@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1738446670; a=rsa-sha256; cv=none; b=0N2X3bHZP9iIGy4cy7MaPtglq2tVMeQwRGcIrVS4UjG9s1N8tKCFRLIdzWdOUI9z5DQLVA 10frfkyRHE4YakmU3k2jWzlIFE9U7Xcxhag+Yr1KXuMNOHMJDlpoI/tP6uWXaa5duAr9wI /sACgd84FBQf/iJ4JT1l773DUPN/KY8= Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-385de59c1a0so1693287f8f.2 for ; Sat, 01 Feb 2025 13:51:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738446668; x=1739051468; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=y6+6LjaugE0DyQnf73qvCDL5j+VRZNBEK4vkemWJG2c=; b=WMHxX/Ghj+BbHEetJUrhD+eh1eUeDUtDs4YoNwRCsjEmIYjimGzOg92ct59zvizp9M QuUa7m51voERA+w8XIkfHbA7YP3/a2Cr9ytEHkNzi9TL0XfuKQNixcoSXE/TG8u2AZSU VCSCUDdOEvQzwU6AG3962Ku5E5SV9BuGM/vJDEPUsq9MvRuVUJMjPzr+/g96+XrNx0UU XKYVWhL4Eqs2Oa1i9L0Mev9E2nU2m7Zqi9I//k990PKzvSWdx+2XFuldVdJYX2VxeL+L X0GpNpOOEZyVN8n12Gqiu8Q2T6nU0rwpHqikKdlKTNhFbxL4a1P0d+bQTI373nhE3SqZ H6hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738446668; x=1739051468; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=y6+6LjaugE0DyQnf73qvCDL5j+VRZNBEK4vkemWJG2c=; b=n4/dWcjB5+n0vm10TrmSztxClWBbvT6CSVioGzdZGMEgbnDhOwmyNDRZuGNxJ/sZsT yMD9A0dLhQClaQGC1eq1l6wIl64l+xh+xUOaOthP0Go3zEKkrD8qDd/48V5tIuGgDzP7 QJ5TaK60pdWN4X0hog86of3HKQLa/kROsYd4PKNW4jdu4w+WWumWaH3Kkk7b62L6Yxlr sGqTPzBvqlrqWZ82UxNiROGLwaxOHHxrm80rgF9CWRMyHNM6ihtq91iG8o9uybYLTrks Z0sK2hoMzKKBK9twrxN28gIMcs3o1D+PuSazBiqpNOMOVI67fQTj8wxpHZSZjWNaCKgg Talg== X-Forwarded-Encrypted: i=1; AJvYcCWiVN/NvFrx+T3DCZ5nltwCPFjI2HOf8zEoEH7eXqzERUYWtbjRwltlGRUjPfR1hVtA/Lm7gKKA9A==@kvack.org X-Gm-Message-State: AOJu0Yy0IEH4jIzYf28xYHnCFBrl80XDFKlJowbvRKqVdPFuseigShHf zYXnl0swxcAT3Kb0VGhLbT84JFo8xLvVUKKM8lk045bbKFk3bdnt X-Gm-Gg: ASbGncv72kOvqqHTeOiNTCFUA3NQwyPCRAwC8p0expxQnxQEIkXNlj7eGYOmy8FdfrX q+lkBxJWhi6FcsckfBTp1j2ULjCK840EaUXLkdnT00yFWkbd35KfqlDBbbRrALd0cgFoeUDmjnn S5hccsE4GaNyqOL7N9KGxRVVe3T5EUuGY/Gl3qynJA+1Vd4j2zWjHtk07Pjhfe7TF5fDcHSTWDs e98mvsyjJlqN7s6qLHUQTqhrClwcjq9T99eNNN993e8ajGPBBk/9IfBSP96J7d3rErBjWiTmAlX vXCn3pGYj7TsNq9suFOLiX9JWw/zOvBe2cv5Ebe8pwLqum+1I2Meow== X-Google-Smtp-Source: AGHT+IHYRiLd3QDJnOn5b+AXIOzWtb3HxAVhHzU0YObH3osU8dB6+cLswxUn6gthx+zEs/IB7VYZBg== X-Received: by 2002:a5d:5f93:0:b0:386:3213:5b9b with SMTP id ffacd0b85a97d-38c51e8e12fmr14080788f8f.43.1738446668128; Sat, 01 Feb 2025 13:51:08 -0800 (PST) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38c5c1cfa3dsm8391149f8f.93.2025.02.01.13.51.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Feb 2025 13:51:07 -0800 (PST) Date: Sat, 1 Feb 2025 21:51:05 +0000 From: David Laight To: Mateusz Guzik Cc: ebiederm@xmission.com, oleg@redhat.com, brauner@kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 6/6] pid: drop irq disablement around pidmap_lock Message-ID: <20250201215105.55c0319a@pumpkin> In-Reply-To: References: <20250201163106.28912-1-mjguzik@gmail.com> <20250201163106.28912-7-mjguzik@gmail.com> <20250201181933.07a3e7e2@pumpkin> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Rspam-User: X-Rspamd-Server: rspam09 X-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EvSFSteUJM0wAh5d1lAIpAoPlGTyN9NXaB370cX/PqBMAFXBNpdl3/K/i1FxWU7R3e5oXpAQ+38akFZi1fSCtUwB3QI5YvwRTlqG1xZUPYPaCC/DrTDQTN8vT7JYdqGSANW2gTesxqBHHB46RTrSMIvnq2Y73DTG5kiLJlXzsaz1Q/yF4hkHW7nVhahLL7RjzXxQTvMjLg8ILI9gJbcrpX7VXQrHhQ7QL2Rjd3D8jBDPADtz2guSgKkUGSsL8YWP8ynsFmrbCx6lisPetgzpE2CZpiGMVj19sSREIoxFNATFwljtbigiaCC6F+I1OaWt5AAAJ82e9gvtQ7D4D5rxtGERlLbwPAg8XDSludDn+a/8G06vhJD1OrKdFOLt6v77Ag5D7+D7z+q9BcbTeyUvTE+GTYxs2EdVkk8OgoaYNxz0xfyrWQZUdsV7qaMFgJ4zTbq1pb9qy9ag== 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 Sat, 1 Feb 2025 19:42:32 +0100 Mateusz Guzik wrote: > On Sat, Feb 1, 2025 at 7:19=E2=80=AFPM David Laight > wrote: > > > > On Sat, 1 Feb 2025 17:31:06 +0100 > > Mateusz Guzik wrote: > > =20 > > > It no longer serves any purpose now that the tasklist_lock -> > > > pidmap_lock ordering got eliminated. =20 > > > > Not disabling interrupts may make thing worse. > > It is a trade off between 'interrupt latency' and 'lock hold time'. > > > > If interrupts are disabled then (clearly) they can get delayed because > > the lock is held. > > Provided the lock is only held for a short time it probably doesn't mat= ter. > > Indeed, unless it is the worst one, it probably doesn't matter at all. > > After all spin locks shouldn't really be held for significant periods. > > > > OTOH if the lock doesn't disable interrupts then an interrupt will > > increase the length of time a lock is held for. > > This can be significant - and I mean upwards of 1ms. > > Network interrupts can tale a while - and then the work that is deferred > > to 'softint' context happens as well (I don't think a spinlock stops > > the softint code). > > > > I've a feeling that unless a spin lock is held for 'far longer than one > > should ever be held for' then you really want to disable interrupts. > > =20 >=20 > Note that taking the interrupt trip increases single-threaded overhead. I'm not sure what you mean. Disabling interrupts isn't as cheap as it ought to be, but probably isn't that bad. > Per your own description, if the lock is contested and interrupts are > disabled, handling them also get delayed by CPUs which are busy just > waiting (and which would otherwise take care of them). The slow path for spin locks ought to have interrupts enabled. But, in any case, the interrupt is only delayed for the short time the spin lock is held for. > So while this is indeed a tradeoff, as I understand the sane default > is to *not* disable interrupts unless necessary. I bet to differ. If an interrupt is taken by a cpu that holds a spin lock then any other cpu that attempts to acquire the lock spins for the additional time that the interrupt takes. If interrupts are disabled then an interrupt is delayed for the time that the spin lock is held. The execution time of an interrupt can easily be a lot longer than most spin locks are held for. Either because of the work that an ethernet interrupt does (even before deferring to softint), or because even a single PCIe read (eg to an Altera Cyclone V fpga) can easily take 1000s of clocks. Now the execution cost of the interrupt has to happen some time. But you really don't want multiple cpu spinning waiting for it to finish. David