Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2169115rbb; Tue, 27 Feb 2024 12:56:34 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVib5Tkk7wdoqq/jNRUfdvbdNOyMnfZ4+jI+ThyxT6E1CaU0XlmrNzr/l4QsmSd3sNatqBfWZLO1btr+SX+InRd3b0C9vnI6dgUzk2VDw== X-Google-Smtp-Source: AGHT+IHwNenplonGWGnvbdfckatMRZwqf6QM+/tNHQPd44m670Ve3sSLCYRIt7IKFbU3Q/4Gguco X-Received: by 2002:ac8:5f07:0:b0:42e:7fd6:9dc5 with SMTP id x7-20020ac85f07000000b0042e7fd69dc5mr861269qta.22.1709067393750; Tue, 27 Feb 2024 12:56:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709067393; cv=pass; d=google.com; s=arc-20160816; b=zA0yFl1AtNUp0BUTcM9ALKbs5etIT2qaCMh+1qIVsAK6fVfRWMt5aZiO0yf2QFo8/h ioSFZEkOXfLP7dTD4EG0Lj4V2yzY/jDGsXpSyLh/bo5C8jpu/jAqi9GnxxT2l/GdbqsI 2Yr0XY6Tuq5sxkC+p0OVo5xqdDW/P2R6lq0gAeAz95R0fXpJJKSYXjE6HmAPBL1Kev07 n0rM0g4zzLifm2DycHm7L2R4jamHTyuLRm4+C1VMFs/79otc8PM+awtIPSepgnYGma4f KALQVb+vmsJBVq9fIy5MDWSBiHevuhGFURBXifBbe++rkuxE58YvhYiiCGddAHV8RNoX wmJA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=UKCWCT93031ctnu4e0l2nLLoQn5zgMFTn2j+yBK/CsE=; fh=PVDa6llaXxVqizTjx6bvE1U2+ByEn/c4m/1uA7l1wfw=; b=QT6Vt0+dFCR2LTvvCseJd1lQufak58tkhyI5KOjE/gOGlGlTp2IHTK/VFZy/uJ2sYZ 58Ib1YMesQxjgk9oUrUoLIgZaj/XZjMe+v1WHqFFLJCCh4d26nEgN5MHj5Tojys8cttH nSLnlr2CCIvrGqw4UZRNNR7AXy33aD4pyhX6zAnFdDHlYcqkIakchQZOzPVoJXpr4vgu FIiFfM2xnn/p1P7M2BVEXD7EYuiQIPs5fpv4a+3/wyV2N7AHLou/TTd8ynArzfjxgtHd Xqmk8AwvYmsHmLsG0UB/lhYXcOAihxmY7cg3otYHCWfbsDYGpKcgNztp8gLuDmpJdW9q HjDQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=QtVGwrYH; arc=pass (i=1 spf=pass spfdomain=linuxfoundation.org dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-84003-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84003-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c11-20020ac86e8b000000b0042e770d48dfsi7830117qtv.35.2024.02.27.12.56.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 12:56:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84003-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=QtVGwrYH; arc=pass (i=1 spf=pass spfdomain=linuxfoundation.org dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-84003-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84003-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 5FFF71C25322 for ; Tue, 27 Feb 2024 20:56:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3961E14EFF5; Tue, 27 Feb 2024 20:55:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="QtVGwrYH" Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) (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 5193214DFFA for ; Tue, 27 Feb 2024 20:55:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709067327; cv=none; b=FcwZVL5b687VFuzEnWJpwTj3rrYmGle+1rKBiL6jmn+OIo94OR34XSUUTjyVT3+UcaMSduThNqyX0+zP6C3+RMWtTVVtrDGfHqWvejfgZ1LJo85ZPo8dp7d8rdiynT3EsI/L01KI7tkG0CUDe9Gl0TocXxuNPrdtlB0mNRJ0YRw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709067327; c=relaxed/simple; bh=cn6YOKUX5dA3ag8i1Tc2HjJMtQinFT7ylVNBEPwuuIo=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=G6eM2iNmVt6ultAKecYuCeLMDILtsPlzNAhkhDJ151tx2OUTYUDVOmw3AKEjCzD0ptabBwp4jG4LdhnZ3xydgbMewpPLW1E858hY7n8IT0Eqz6FW5OhoR/n1zn4HgUIIPfVqqZmfAQC+L2xs08qFnqY1Kw2ZmIAfd6ZuXeeioz0= 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=QtVGwrYH; arc=none smtp.client-ip=209.85.218.51 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 Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-a3f4464c48dso576805966b.3 for ; Tue, 27 Feb 2024 12:55:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1709067323; x=1709672123; 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=UKCWCT93031ctnu4e0l2nLLoQn5zgMFTn2j+yBK/CsE=; b=QtVGwrYHR6ZoSVBDdHphTeDow/uQR0Sh+WtDzvuOtOmiGwye3DA9FZ0VmHakoDckVL prV4JElEDEL2yYI1HjhVw9IdnXVfVJT/b2wX4AIY0OhjSob2XhHr5Ot0p8ff9gd2fePz 4Fa5DEflbJRrIcH6w1xEtTjkUNL62g8uA03PI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709067323; x=1709672123; 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=UKCWCT93031ctnu4e0l2nLLoQn5zgMFTn2j+yBK/CsE=; b=OEoxFZDGGPXFOAhfJqHM2UnNyeZ5AwpTwMsREeJkabsQ3OFT+bwV+drKwQL25ISsyc ue12zCYWtsfea4iZLPkN0/blITN7ZGTHfuQzghdN1JEXXYe8JgDJATv3Aa7sgVXjwh3l r2Dkrr42Xj1ITfgT2IR7bJT/SCOTR41LuTRvNUjogm0keP5/s7QcxvoII2KENsIzRlMC lFfcjl9tBMP1roY5cI5XhRjOfe9wmbUhuTBYlpJnV57/o1Q9CSThIVWDrQF59umduDLG zdNuabV+vwPHLExNw9uzFjFB15kNlQ1cqXw+elcA+sgOQHN2nsHO9nKhYVLTcf7OWftW xlgA== X-Forwarded-Encrypted: i=1; AJvYcCVJ0lrJcx25fDHiX9dg+v/JrX2e7pCF0YwEG3RH7UAK4Ii/du3Nu/xE7F5pmPzB6wdPzqwUSErVqFH+cTxEYAc1TtcSMO8Opw4WlyNT X-Gm-Message-State: AOJu0YzFG/6pcDnyVwekzg+k9JXTZv2dP1Q85tArlJ0+urDyEFjosv3L 4p8SmJr2vACpsfOXZ6hbucP/RnhvuglhDEMDB+as7e8rQ5i6zX21fH+P72dhe4QTjw5csSFdV1h /B7r8Rw== X-Received: by 2002:a17:906:a3cd:b0:a43:3b32:3906 with SMTP id ca13-20020a170906a3cd00b00a433b323906mr5432454ejb.27.1709067323514; Tue, 27 Feb 2024 12:55:23 -0800 (PST) Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com. [209.85.218.54]) by smtp.gmail.com with ESMTPSA id j3-20020a1709062a0300b00a3e799969aesm1104174eje.119.2024.02.27.12.55.22 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 27 Feb 2024 12:55:22 -0800 (PST) Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-a3e7ce7dac9so540186666b.1 for ; Tue, 27 Feb 2024 12:55:22 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXwS1es7+zmBEJk7hn59/dgYdYMYYimgY2dSMyhtBdJWW5O/TnXJFNBsJdFJmgYEogsbcy07Q67wIBdZpCj2XnGzLFriNHM1VS4+Heg X-Received: by 2002:a17:906:aed1:b0:a43:dbd6:6862 with SMTP id me17-20020a170906aed100b00a43dbd66862mr957734ejb.73.1709067322332; Tue, 27 Feb 2024 12:55:22 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <170905252721.2268463.6714121678946763402.stgit@dwillia2-xfh.jf.intel.com> <170905254443.2268463.935306988251313983.stgit@dwillia2-xfh.jf.intel.com> In-Reply-To: <170905254443.2268463.935306988251313983.stgit@dwillia2-xfh.jf.intel.com> From: Linus Torvalds Date: Tue, 27 Feb 2024 12:55:06 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 3/3] cxl/region: Use cond_guard() in show_targetN() To: Dan Williams Cc: peterz@infradead.org, gregkh@linuxfoundation.org, Ira Weiny , Dave Jiang , Jonathan Cameron , "Fabio M. De Francesco" , linux-kernel@vger.kernel.org, linux-cxl@vger.kernel.org Content-Type: text/plain; charset="UTF-8" On Tue, 27 Feb 2024 at 08:49, Dan Williams wrote: > > - rc = down_read_interruptible(&cxl_region_rwsem); > - if (rc) > - return rc; > + cond_guard(rwsem_read_intr, return -EINTR, &cxl_region_rwsem); Yeah, this is an example of how NOT to do things. If you can't make the syntax be something clean and sane like if (!cond_guard(rwsem_read_intr, &cxl_region_rwsem)) return -EINTR; then this code should simply not be converted to guards AT ALL. Note that we have a perfectly fine way to do conditional lock guarding by simply using helper functions, which actually makes code MORE READABLE: if (!down_read_interruptible(&cxl_region_rwsem)) return -EINTR; rc = do_locked_function(); up_read(&cxl_region_rwsem); return rc; and notice how there are no special cases, no multiple unlocks, no NOTHING. And the syntax is clean. Honestly, if people are going to use 'guard' to write crap code, we need to really stop that in its tracks. There is no upside to making up new interfaces that only generate garbage. This is final. I'm not willing to even entertain this kind of crap. Linus