Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1034701rwl; Wed, 5 Apr 2023 10:53:14 -0700 (PDT) X-Google-Smtp-Source: AKy350Y0d5f80F6rXtIy9x7BTRcchCXwkPrq7Wx/GMVS82bZWuQt17rcnkSOhxpiefBCkEw2Hg5S X-Received: by 2002:a05:6a20:4726:b0:e3:7651:44d with SMTP id ek38-20020a056a20472600b000e37651044dmr36064pzb.20.1680717194371; Wed, 05 Apr 2023 10:53:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680717194; cv=none; d=google.com; s=arc-20160816; b=wX1PLeDuE0enLS20oGhWA9SwPvVI90B/SW6CbZ0ffOQzk9cBrm0V4lao25eRqFDAMB YxHlHHF20eUuP/Alh/1uekpDI1FHiZrTqtLffLiwZgwShbJYEw0tRfBTfC0kJp0hE11u rJzpobXyjibPBdrSO02RR7+C7w5bgZzDGCrJnOC8CDv32jS9qlGGRItF5QDHhNezgdeF 3bpXiJEmJYDk4ulKdOJDKWL8fl6qDMMPRF2BAboYcF45sogoltCIipaA/N6jcYvuz4Cg ujSa9midoGEIXP8cHeDm4Q+i5lWZIeX8hHZkno6QacIwpE6mJ3RxTxnCjlQmtOjsNOrP gzcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=NWfXCnCRLHGCdfIApvX9+B1Kyu8tR4YNh4ctx6G09S4=; b=ffOCbqWGRJgYS5YbCkm2qMTDQ9lCmI08/G55q5/DpEp8zJrbL6fivyXawqRcFng+i6 6UURxaBkUQFAqLiJBAsQreKHBSaQtKdEYicbSo9XDuc33R6SN88rvynqySc/0doVZBlb Z0s4nyrPLPmkm+QGWEFtl+wgjF35+gZ3B0XKO7UK1GubnWXEK8Ty+wbYrJbv+XqmkgDO ZhiF/qsEHgJ/42EqCNZUtbljShEWp3mYt6CkZ/MF2RSAUB3Io0WcAuBgnOOg6vSIsppQ KlnAfuYyuI5qTtycZFerpepRcOST9mCrsA1lQvQuUNF+DpYXKhHdkDK59rk2FdGAV3hx LUXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="Ka/svnAH"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y1-20020a636401000000b0050726756ee2si13228267pgb.96.2023.04.05.10.53.02; Wed, 05 Apr 2023 10:53:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="Ka/svnAH"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231828AbjDERwE (ORCPT + 99 others); Wed, 5 Apr 2023 13:52:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231564AbjDERwA (ORCPT ); Wed, 5 Apr 2023 13:52:00 -0400 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B2516591; Wed, 5 Apr 2023 10:51:59 -0700 (PDT) Received: by mail-oi1-x22f.google.com with SMTP id b19so27233463oib.7; Wed, 05 Apr 2023 10:51:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680717119; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NWfXCnCRLHGCdfIApvX9+B1Kyu8tR4YNh4ctx6G09S4=; b=Ka/svnAHZR+5faSaZQK9uR5ULlK+zzKrSaBtJLoNuMfsdOw62K8ztnFxbZ5NRtbVQF ul/Ju8isfNSoJoiVnkLcQGZ9VuOo6vWfcuFnwJkvlGOpsKn4pi/zHS7Djb4dxn5ywYBR UYwaItHimsDc4HSyx+7DYUyHP2kcC9sRClOjJPTknmW4mFoCeuK8mpb6B4yjljM/9N/F 1Q9vZvaMxsj/7a/W7kzBnvKsAt1n4EaETqIQkzJ0JD8ncpRvcHE6aLBsPp1rj1z4z7Bx FJ+CRsDRm60NgahLiPMhD4Qk3xam8KHE162pHCjU3jieBlwiizeY7mF0Miw0VZepD2aM mAFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680717119; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NWfXCnCRLHGCdfIApvX9+B1Kyu8tR4YNh4ctx6G09S4=; b=G1a61ZhOFZEWJ0vdnSR3K2/U5GoNDRY5aFF/LSIQThqJm5ldDzIinOBfVnN3ZVNAoo 0ZCFKcPlasLQEpMXQWffmnDlMmaG68Q8kssnXGaka5kB3eFYqyzCxl9Pq6EUNHLtgMFr kQkARr6LXkxSbHm8QI5V8mwATbDxHTMf/DeH85mfjl2tZk7XUgdC3O3WQMuf2mfWY296 qttj6gFZ0v7VFEzPe3IAiDiq/BLq/PgKTO9dhJYkg6CkqoqIg+yvWxxTMvAL6wgnF2IW O/eHGoi8sMGvcQdmlKyj9KdP7UFUVNMIOql309tb6hv5huCFAw2SzzNd15VjqkhjmLH0 BLWw== X-Gm-Message-State: AAQBX9df6QFP5/Rw+y1D3hG+hpwGBn6Mw368qCjmXENWu5JQAI56dVeI n4+XfEKCa6mYZ73Mz18OAL7HNsZw4W5nEg== X-Received: by 2002:a05:6808:2b02:b0:384:118f:f9c5 with SMTP id fe2-20020a0568082b0200b00384118ff9c5mr3120794oib.25.1680717118868; Wed, 05 Apr 2023 10:51:58 -0700 (PDT) Received: from wedsonaf-dev.home.lan ([189.124.190.154]) by smtp.googlemail.com with ESMTPSA id w185-20020aca62c2000000b003896e31867esm6604045oib.49.2023.04.05.10.51.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 10:51:58 -0700 (PDT) From: Wedson Almeida Filho To: rust-for-linux@vger.kernel.org Cc: Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , linux-kernel@vger.kernel.org, Wedson Almeida Filho , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long Subject: [PATCH v2 04/13] locking/spinlock: introduce spin_lock_init_with_key Date: Wed, 5 Apr 2023 14:51:02 -0300 Message-Id: <20230405175111.5974-4-wedsonaf@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230405175111.5974-1-wedsonaf@gmail.com> References: <20230405175111.5974-1-wedsonaf@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wedson Almeida Filho Rust cannot call C macros, so it has its own macro to create a new lock class when a spin lock is initialised. This new function allows Rust code to pass the lock class it generates to the C implementation. Cc: Peter Zijlstra Cc: Ingo Molnar Cc: Will Deacon Cc: Waiman Long Signed-off-by: Wedson Almeida Filho --- v1 -> v2: No changes include/linux/spinlock.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h index be48f1cb1878..cdc92d095133 100644 --- a/include/linux/spinlock.h +++ b/include/linux/spinlock.h @@ -327,12 +327,17 @@ static __always_inline raw_spinlock_t *spinlock_check(spinlock_t *lock) #ifdef CONFIG_DEBUG_SPINLOCK +static inline void spin_lock_init_with_key(spinlock_t *lock, const char *name, + struct lock_class_key *key) +{ + __raw_spin_lock_init(spinlock_check(lock), name, key, LD_WAIT_CONFIG); +} + # define spin_lock_init(lock) \ do { \ static struct lock_class_key __key; \ \ - __raw_spin_lock_init(spinlock_check(lock), \ - #lock, &__key, LD_WAIT_CONFIG); \ + spin_lock_init_with_key(lock, #lock, &__key); \ } while (0) #else -- 2.34.1