From patchwork Tue Dec 30 20:51:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1115 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767127956; bh=O2JJOHkLeT8ayZUxhdYhLBt9oG7wa8fCkLZFi7qrzKk=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=V3vi/e3iuen2OVTZjW4H1YtnNbCsl00RlnY5n2AV/vZo9Dxf4EUX6Gg7BuX+C9Zi7 SjfSDsK7xC4ix4dK9YHFiHTwzTICGsnly4XiBD1jBQUGft0C+7sTJMUCmfe2+8D4vU xmgyxYOFH/P4WGJLgr+cdoSmm2L8VB9EDA19hJzXf+ulkmW/yAwiIUk4Lo/wxryxO1 D362f87mvHDAW+Td3IgpRwhO457wGS1gW4I8joZWNk77WQ2kAhKiVKPWpISWYrj8aK cGHOi9yVbzP6WehQAdPChGKpcFILCx00miUxV7DCVYsnle0VU/K9Jb+rofyvJhc11x vbkkZXaik916Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C968668C0D for ; Tue, 30 Dec 2025 13:52:36 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 7WaxFQzrDgI2 for ; Tue, 30 Dec 2025 13:52:36 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767127955; bh=O2JJOHkLeT8ayZUxhdYhLBt9oG7wa8fCkLZFi7qrzKk=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=uPoAKml6+j381cJNzxsApeEkxxz9Ag/OPuYg0qFUus5wzZpZeTJ7XV85U2mCvAP5Z dq/+r84msycB3wr3otrjxTT0aGP8tItoR1KCulkFVIUu5F+p6xPWfzfdXclmzkowkc TdlDEJhMEIsOZZxfM+R1NOGyUxf2sLgrXMvijtHI1H+viPFLFZt5PGhDk9Ie9NYtwT IEPqJusq+YdeClJrHwjDQh3Lv7MVLa8dSciiSCb7gE2fiA4TIR9ECdz6myWMl1HRWH uKJNaQ5FNdL52tUokhLLS7M9EXg6TNkIVLIkDGg8pSsAXkq0DQd0CdibENk4dc7SaO mn5OWvV7TKbYg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7B06668F81 for ; Tue, 30 Dec 2025 13:52:35 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767127953; bh=D69pJr1uFLWLePd31rCRGmyWkgq/gIGLw+jPfvCXvGc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lgKW6hS1sBFHWOV+BxqxPf2RQlfcFHejn/f5x48+WO6bB85Bkcay8/tq9QG4g5TvF Z1uw2hRmfrh2/p6FE2iN89UiA9wTBm87CB/WbqIyA8jWLemLOTiO/Ap4umZ2neYYYw W54BQzRBnbYjMSynXc9sFb2YzrOMYrr305f+vuwiC3a7ye4++YS1Vl73AN3LKTk5Pm LBHDFp1H+bzWl2wKQ3474ubEZnhhr/Q6T+Y5vT1jRQ3Yx3sYs8a3oxMkqldUtIDUQg RsCXSyBW1ItoApXl1Y0nB18F8pMwcXj7m3pl9PmOeTgy8OqqGXQYSrBT69zflSTTvy cvp21qH8a6Wrw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A527C68C0D; Tue, 30 Dec 2025 13:52:33 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 7GKEfxRn3Iiq; Tue, 30 Dec 2025 13:52:33 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767127953; bh=rd27jupZFFCdSLf3GwyfIQLGxakFG+b13oEO3F6rXig=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MkSpJr6/q+GTWN1ngUJb0cy8tUh42vElODzCpaCndiE54kZHAv0X9Z0CFIxFV2Dek XCpSWLhFbkd1n0ZDz1GPs/jBpcpa4g1YgG097HEYQFW+aKJqEUMdErEPDLL4HV40w+ p+tPIhmAUi1fDr66UHuBV15/xqtLvo8UkS2wr7xdy8qzW1UzBil3XPPziRz/wmOV5b YEOLDzvyeUpa+eqO6Rauq6OJUQGxaEmW4Ar4fpmP1OCyWWYJYONmX/veoNCvTrGg4i 1E05ged1iqVA7ISolpLSKlSljRS15e4j3xPSqwyNQO9FGjJcb7MbqTATa3VZoD4m0+ jJVqB9hP4GoEw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 171A068BF0; Tue, 30 Dec 2025 13:52:33 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 30 Dec 2025 13:51:43 -0700 Message-ID: <20251230205157.3383926-7-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251230205157.3383926-1-sjg@u-boot.org> References: <20251230205157.3383926-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 3RTURXE6C666BNVEFRH6UAWYY5737KFI X-Message-ID-Hash: 3RTURXE6C666BNVEFRH6UAWYY5737KFI X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 06/14] linux: percpu_counter: Add initialized field List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add an 'initialized' field to struct percpu_counter to track whether a counter has been properly initialized. Update percpu_counter_init() to set this field and percpu_counter_initialized() to check it. This is needed because ext4 uses percpu_counter_initialized() to check if counters are ready before accessing them. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- include/linux/percpu_counter.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/linux/percpu_counter.h b/include/linux/percpu_counter.h index 58d52d01310..6a8544f7f79 100644 --- a/include/linux/percpu_counter.h +++ b/include/linux/percpu_counter.h @@ -15,6 +15,7 @@ struct percpu_counter { s64 count; s64 counter; /* Alias for count - some code uses this name */ + bool initialized; /* Track if counter has been initialized */ }; static inline int percpu_counter_init(struct percpu_counter *fbc, s64 amount, @@ -22,6 +23,7 @@ static inline int percpu_counter_init(struct percpu_counter *fbc, s64 amount, { fbc->count = amount; fbc->counter = amount; + fbc->initialized = true; return 0; } @@ -76,7 +78,7 @@ static inline s64 percpu_counter_sum_positive(struct percpu_counter *fbc) static inline bool percpu_counter_initialized(struct percpu_counter *fbc) { - return true; + return fbc->initialized; } #endif /* _LINUX_PERCPU_COUNTER_H */