From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8102A189BA2 for ; Tue, 31 Dec 2024 19:38:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735673920; cv=none; b=BA5eFCuBatvDSz2GB0u+JEPyISbIQ8hasjnrUVsKVYnFmPzhqLM6jUK9HbIlHyQ0YIYoleHqkrNdKFeB2zL6CL7x7ubnYYHalI9x5qMX/2GK9n2jJveQSIKI5OtRAOUh5NvLObnijjHXOMQmPndZzWkHV4uzOs8HwZraF7mzROA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735673920; c=relaxed/simple; bh=S6SHi/u4tc00nXT9iEVnJsQvTdlaIbqdZrdUu8oFXp4=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=IGcejO2PrfDNIzybRxSL6C5/lUwHmZ7fbUdcYDsj0ed/eZ14mttM/7V9cX9CItJUgP85ECkdDc+LYO7juDQAQtN9r9uGSWH5Thg1FROx8OkRHrb63SVXV4kwYsPfEUkLa/PEEBSMkXEcVnq7Ngkdn5snqtBuL7c/ov9SYdfwjVo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org; spf=pass smtp.mailfrom=linuxfoundation.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=QelWW9Fp; arc=none smtp.client-ip=209.85.208.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linuxfoundation.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="QelWW9Fp" Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-5d122cf8e52so17356464a12.1 for ; Tue, 31 Dec 2024 11:38:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1735673916; x=1736278716; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=sdJcAYSET8NoDs3C+Yvx1lUTBNZCtlSJkdQ7vJDaRmg=; b=QelWW9FpBoN8wteoLOZKfiK6qZZBgdIUQwPq1Bbh8ZeoidjiRxdmdNYBFJM5nb/0vk Rn14Rof9DP2ny3L/c8NMbU7nLNi0Jj/umnxclO2X41e94tfRdYOQ3DeKfwcx44L7chcc oXrLm32zkjBaM9YtKAkPGLOMMchloxXriP+2k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735673916; x=1736278716; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=sdJcAYSET8NoDs3C+Yvx1lUTBNZCtlSJkdQ7vJDaRmg=; b=q+/K2UqKpCyYRaa5qsmuGBGgnc7xc8pgs9JZ8vmfEDIx+4n+ANIbsI2m0ZukBbvaFY yaRmBNVtZ0I1yhDTo59lhuqluWeylixCTLYAp0OlLOL6lETh9BAEvsuZE31QuAp/Qm/d LXUF3Yul74YOP+TTvTJD0wAAL6wFderb/a5HN7aR4mavq1gyYNwO1d+y0Fl8q+1tN1tw dpxpWN41J6BL1lTFcVj+2bQED9WMrpgTddiM5KwhiV7rwHTTnfhL3g8DvrK7TQsUNZEP GCWzPneM3RqTX+VL2Bq8Ot/YX812neICZ21bhtJ2YEeh4pxVINCCPNJCIoXntxjgc+vi 9JLw== X-Forwarded-Encrypted: i=1; AJvYcCUgVvLx+iCISyFbQRDmjNy/TkzBZKz97Gm0PyYDIdH3eDmshzn7gNW1TTBerdNhTMDqsy20Fw2UpOPgpQk=@vger.kernel.org X-Gm-Message-State: AOJu0Yx5EFVX6uI8K6ZhZzKJArYdNLBbA0wsSRWuUnLujJ31qdjVr8Fq 6CtibovsuKRKmpRuVGsJ3XE0TJrwi7ADwsbyEDnf13kIYjMsZT/kmrTrMBVTNQXITWiWwWXerG3 R X-Gm-Gg: ASbGncv4fP4nosJUOvkjga+DW0AecPMxzg0o+KegX71n4ORXpTcJhotJ+FYuygY0M3k pLctAa6PlFp4f6Tq4ErI8+uIVASWvtHnMaG7SuSiCsdbq//iXLjnxtQ+764pXVDrEEGh4dVR9Lo uuGTAdzwBo+crlrgOrwVcHfREH3fmOmI9Fcdc7gKn4bsl21vBR6cloBdD49bFMcVmwZT/LxFCo+ De8COcntEk7/GFZWaWK+nsrfpHK+7z/DKQpzzZlvF2ZRxWaQrkJoNegOw2KH4yuVAsJzLdc9Aam UbUXyaTYz+JbTdntGz+xz8vvPHfbZ8k= X-Google-Smtp-Source: AGHT+IFuga/v8r95DXF7D78cKlNHzMpkBC9TsbgGzp6x4buXYtjDSrv9TKDS5T4wiFZAyB5I705HIw== X-Received: by 2002:a05:6402:540b:b0:5d0:d610:caa2 with SMTP id 4fb4d7f45d1cf-5d81de1ed59mr35912018a12.26.1735673916191; Tue, 31 Dec 2024 11:38:36 -0800 (PST) Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com. [209.85.218.46]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5d80701c8a5sm16162371a12.86.2024.12.31.11.38.34 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 31 Dec 2024 11:38:35 -0800 (PST) Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-aaf3c3c104fso549022266b.1 for ; Tue, 31 Dec 2024 11:38:34 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCV4xMzfhCtBMq2Mk+CfChMwN7CYlnG7AJ6bGabWCvbbEKZ8Ukdr6F8LjACSP/NgL75l1ufZDpvRJo635IA=@vger.kernel.org X-Received: by 2002:a17:907:360b:b0:a99:f6ee:1ee3 with SMTP id a640c23a62f3a-aac334f624amr4462682666b.43.1735673914276; Tue, 31 Dec 2024 11:38:34 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20241230153844.GA15134@redhat.com> <20241231111428.5510-1-manfred@colorfullife.com> In-Reply-To: <20241231111428.5510-1-manfred@colorfullife.com> From: Linus Torvalds Date: Tue, 31 Dec 2024 11:38:17 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RESEND PATCH] fs/pipe: Introduce a check to skip sleeping processes during pipe read/write To: Manfred Spraul Cc: Oleg Nesterov , WangYuli , linux-fsdevel , Linux Kernel Mailing List , Christian Brauner , 1vier1@web.de Content-Type: text/plain; charset="UTF-8" On Tue, 31 Dec 2024 at 03:14, Manfred Spraul wrote: > > Should we add the missing memory barriers and switch to > wait_queue_active() in front of all wakeup calls? If we *really* want to optimize this, we could even get rid of the memory barrier at least on x86, because (a) mutex_unlock() is a full memory barrier on x86 (it involves a locked cmpxchg) (b) the condition is always set inside the locked region (c) the wakeup is after releasing the lock but this is architecture-specific (ie "mutex_unlock()" is not *guaranteed* to be a memory barrier (ie on other architectures it might be only a release barrier). We have "smp_mb__after_atomic()" and "smp_mb__after_spinlock()", but we don't have a "smp_mb__after_mutex_unlock()". So we'd have to add a new helper or config option. Anyway, I'm perfectly happy to get these optimizations, but because of historical trouble in this area, I want any patches to be very clearly documented. Oleg's patch to only wake up writers when readers have actually opened up a slot may not make any actual difference (because readers in *practice* always do big reads), but I like it because it feels obviously correct and doesn't have any locking or memory ordering subtleties (and actually makes the logic more logical and straightforward). Linus