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 X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86F3BC388F7 for ; Tue, 10 Nov 2020 19:54:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2FE91206D8 for ; Tue, 10 Nov 2020 19:54:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="hWBEx6QM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731755AbgKJTyk (ORCPT ); Tue, 10 Nov 2020 14:54:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731613AbgKJTyi (ORCPT ); Tue, 10 Nov 2020 14:54:38 -0500 Received: from mail-io1-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A723C0613D6 for ; Tue, 10 Nov 2020 11:54:38 -0800 (PST) Received: by mail-io1-xd43.google.com with SMTP id u19so15617831ion.3 for ; Tue, 10 Nov 2020 11:54:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vJU5BF5XUBg+xDNSMiAC8MnJi+PijhO7PLpt5hzre/4=; b=hWBEx6QME80sNP6u2IId4qFwe/A0iEcMW1hZC+POySD/V3cvoUOaZYvmHrKB0jNVWY IQTbrE+m8h45Pq4a7q068aD8d7YTati8uMJ8yS3sQ3lvHMlB7hQjf7DbXdnpxfJqV5yG eGvkPB5rvJmRABPLqNQkNHU6iiCQasGEIl+DQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vJU5BF5XUBg+xDNSMiAC8MnJi+PijhO7PLpt5hzre/4=; b=m61Wg5yLXecgQf43lf3FgBmkHMjdY9yPZ+5cWxvL9Dmmpe2DJoKlMZ1ieNf+C5sP8u 6sg8PKfVMTi/Ic8n0fSnSw+XqnW51u+io4bYFn3e1J/3Kth2ZL/NF7/h/JgxZj4BsrbU m9wP1NaPEucIkPSK6iY8vyT+PpUW9MbcJIXM5ZiDiB8sbtUGRvB4DoqXlbW3nQaG59Z7 chJf/ySZFWHDg1LrH/OoC28bT1ho6rt4k1C4WbW/OZFNMCWn/Rx2Wo61qVwsPaH2cV4b ULsFG5hM0s2Yuwp916vitJwoKDTI9tveQLu0h1vJaC5I2BFPtDfwtFRAcDpCqXskBlMf rwjg== X-Gm-Message-State: AOAM5319GY9S6JQ4cq60DzBx1/sCA/kznFReCnpgQsH6R1A1gGSKYzfq LWed5BVSWOmrfmM0mbNFlABwVNKS/ZB/Lg== X-Google-Smtp-Source: ABdhPJxZq4Mqy2gKrCi1yrxiEmOjXBXpfjvBZnB9eJy+Qq21MyWJG4bCHboxEnZ4sQP9xK2EedVD5Q== X-Received: by 2002:a02:c884:: with SMTP id m4mr7112536jao.43.1605038077545; Tue, 10 Nov 2020 11:54:37 -0800 (PST) Received: from shuah-t480s.internal (c-24-9-64-241.hsd1.co.comcast.net. [24.9.64.241]) by smtp.gmail.com with ESMTPSA id o14sm123971ilg.71.2020.11.10.11.54.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2020 11:54:37 -0800 (PST) From: Shuah Khan To: rafael@kernel.org, james.morse@arm.com, tony.luck@intel.com, bp@alien8.de, gregkh@linuxfoundation.org, keescook@chromium.org, peterz@infradead.org Cc: Shuah Khan , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/13] drivers/acpi/apei: convert seqno to seqnum_ops Date: Tue, 10 Nov 2020 12:53:30 -0700 Message-Id: <59277751de83120741466b56beaefd75652c4de0.1605027593.git.skhan@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org seqnum_ops api is introduced to be used when a variable is used as a sequence/stat counter and doesn't guard object lifetimes. This clearly differentiates atomic_t usages that guard object lifetimes. seqnum32 variables wrap around to INT_MIN when it overflows and should not be used to guard resource lifetimes, device usage and open counts that control state changes, and pm states. seqno is a sequence number counter for logging. This counter gets incremented. Unsure if there is a chance of this overflowing. It doesn't look like overflowing causes any problems since it is used to tag the log messages and nothing more. This conversion doesn't change the overflow wrap around behavior. Convert it to use seqnum_ops. This conversion replaces inc_return() with _inc() followed by _read(). Signed-off-by: Shuah Khan --- drivers/acpi/apei/ghes.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index fce7ade2aba9..aa91998ce6f4 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -625,7 +626,7 @@ static void __ghes_print_estatus(const char *pfx, const struct acpi_hest_generic *generic, const struct acpi_hest_generic_status *estatus) { - static atomic_t seqno; + static struct seqnum32 seqno = SEQNUM_INIT(0); unsigned int curr_seqno; char pfx_seq[64]; @@ -636,7 +637,8 @@ static void __ghes_print_estatus(const char *pfx, else pfx = KERN_ERR; } - curr_seqno = atomic_inc_return(&seqno); + seqnum32_inc(&seqno); + curr_seqno = seqnum32_read(&seqno); snprintf(pfx_seq, sizeof(pfx_seq), "%s{%u}" HW_ERR, pfx, curr_seqno); printk("%s""Hardware error from APEI Generic Hardware Error Source: %d\n", pfx_seq, generic->header.source_id); -- 2.27.0