From patchwork Wed Feb 28 13:53:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Schmidt X-Patchwork-Id: 207870 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp3358570dyb; Wed, 28 Feb 2024 05:55:03 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUaBt5yCYGk+VLN0gUJVVBM6uX4/gHdDYI4ghL/0HzuC03u6exR9GhrNPVq1dV7Mwlfgl9C0nSyWiTN5baNUul8k65FLw== X-Google-Smtp-Source: AGHT+IE5twsOgI4gV4gvQ+EZHRh56r/3bRLbDuIeJaAOPbrNErqnienQUFA7/nBzDDr8ArpfQOjO X-Received: by 2002:a05:6402:4497:b0:566:8608:3241 with SMTP id er23-20020a056402449700b0056686083241mr31618edb.14.1709128503648; Wed, 28 Feb 2024 05:55:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709128503; cv=pass; d=google.com; s=arc-20160816; b=FrJj/d0m/5TWTOeibYqVxVBCZc1Ctw0yqjCp70ApSBxgMMzvLtjnE4r1Gkh31Nr6Hk SGdqG96dHP+gPBZsnw35fW+hK38E3b01d+7oCXhONhmsYKAV+cLP2M/6u5QGGDk5oOIm ahsOczCXJ59r1dEe0cTZ7sJ1XsGECny1vnzrwufAVL9mUYQ2M6A9JtzLxp2r9NJ8Gdfu irce4beI0MA+ABLVZqDS1cWjMsJSXg11aizgffcywEJaIQpXbCHNFcYW+1Y7A55hBQSu to+Du8iEE9VIEAA37V0GwLevDeHtthpIdhQRpUt+eDD0kooDPjLcbSsUWo2xeZ3jHmsc eR8A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=7eik1TFl3fkD2jZ/xnSrKIHXhnveA7D9yMR9JohoGKk=; fh=UFRZQIiQBhT4aypPoRib9uQ9S9QnAHlJ0ue4YgDlZvo=; b=jdSUic9foaovAjGM6XlhVHgfsl0m10r6yLo87xdQgBHtidNar4CWYhcsT3Jr5zADbu D9DsXd1my3JAemY6WfL6wSZFx2rRK/RLhYBtXXq1iZ3Tu7uROZSq1SCIs5FgQNuYBARX 0E1LxGVAVV/HpwPzVAz+fihe6w/zr2GUIRXy5W9WMwU7F+V4qtV3m49QSEovwNxOWBLK SV78baoO/r44cDfHLf8dkM+mbzw/13uSiPhimW0T1PjIl8+Uyg9WBK4CXKp0kqRqZJwN GSQwnJen/XIjw0acW0IORJWxWItESUGJh+4mEzHtrWKLms66IZN1YXgwYGrs/ENTXpBB VU6g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Rc9goBtW; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-85137-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85137-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a6-20020aa7d746000000b00564d3570e85si1662697eds.254.2024.02.28.05.55.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 05:55:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85137-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Rc9goBtW; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-85137-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85137-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 35BE41F26921 for ; Wed, 28 Feb 2024 13:55:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 70FB21552EA; Wed, 28 Feb 2024 13:54:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Rc9goBtW" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 4D89814F987 for ; Wed, 28 Feb 2024 13:54:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709128455; cv=none; b=SusS/aJ65nR9RH5aSdqiZ5fJX7doZjxXFa9Slf/+W9DmSMGsVVRzFMK2JLyOsFdo3P68i/O4VejdeRcA63gKcDwmq5GjfygaGOnLMsLpMIKt7uSl4qVeUiQI2Wfq/ap2diMm4HhOW4qw+hvoPVEiMvOVLZzG6zzI1JymiYf770g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709128455; c=relaxed/simple; bh=aV+01cbnvwYneym9pG1JuXfXvYgIVTFiDpBI353TUkg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=p8LzQZOM7893gFT9JM4YSqYcGQ0ZLrpGtFMZYmV9uR08lFQ+LrlnHNIWv8pn+wiSXCuvkX9O9Qm3Jv2xw7CvXddVRH2TN0HZVRN0RRuXYpMfYi/mIJZtmPxQmz5mHqNJ87HIkfYCUN7xHDTyBedfENjsOVmeUKOyU8jGrC/y1zU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Rc9goBtW; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709128453; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=7eik1TFl3fkD2jZ/xnSrKIHXhnveA7D9yMR9JohoGKk=; b=Rc9goBtWHFYKdDvdEuo2i3ETk27e2AHZZAGLjKp/n/ZQ5nk0jxDmaKJO28yuin6v0wBYge AE4QRsoxzNJwNY1TZvOj8MHtCn9oElJ+vr8P7QVkxyuFXb+00h1Fzkali4BTOeaOCHobRN qbWaf1nMLlKLziFD7yt8muE+JjNbDX8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-203-2abDcOcHNvuNVjn4T_N9AA-1; Wed, 28 Feb 2024 08:54:06 -0500 X-MC-Unique: 2abDcOcHNvuNVjn4T_N9AA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A6AFE10AFB08; Wed, 28 Feb 2024 13:54:04 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.226.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id 854CD1121312; Wed, 28 Feb 2024 13:54:03 +0000 (UTC) From: Michal Schmidt To: Matthew Wilcox Cc: Peter Zijlstra , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] xarray: add guard definitions for xa_lock Date: Wed, 28 Feb 2024 14:53:52 +0100 Message-ID: <20240228135352.14444-1-mschmidt@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792151129995672145 X-GMAIL-MSGID: 1792151129995672145 Add DEFINE_GUARD definitions so that xa_lock can be used with guard() or scoped_guard(). Signed-off-by: Michal Schmidt --- include/linux/xarray.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/linux/xarray.h b/include/linux/xarray.h index cb571dfcf4b1..73a8fc0e830a 100644 --- a/include/linux/xarray.h +++ b/include/linux/xarray.h @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -1883,4 +1884,19 @@ static inline void *xas_next(struct xa_state *xas) return xa_entry(xas->xa, node, xas->xa_offset); } +DEFINE_GUARD(xa_lock, struct xarray *, + xa_lock(_T), + xa_unlock(_T)) +DEFINE_GUARD(xa_lock_bh, struct xarray *, + xa_lock_bh(_T), + xa_unlock_bh(_T)) +DEFINE_GUARD(xa_lock_irq, struct xarray *, + xa_lock_irq(_T), + xa_unlock_irq(_T)) +DEFINE_GUARD_COND(xa_lock, _try, xa_trylock(_T)) +DEFINE_LOCK_GUARD_1(xa_lock_irqsave, struct xarray, + xa_lock_irqsave(_T->lock, _T->flags), + xa_unlock_irqrestore(_T->lock, _T->flags), + unsigned long flags) + #endif /* _LINUX_XARRAY_H */