From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi1-f169.google.com (mail-oi1-f169.google.com [209.85.167.169]) (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 151842E54D1 for ; Mon, 2 Mar 2026 19:48:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772480924; cv=none; b=JGToQZwpMS2etf5dtozYpgHscWv+Z7iMNlJipsc/KY9ZNPGAAn5+vOyqRURJfN8bfWMuDuaZWSWGLVlTQwiA7mNtJNRLMQsQ4NWK6reTVd2dcejtqYFfEnTjaEJEcBNwWveO8CjnXb4TRdFN3ciKythmw1uXFyHhh5UN0KNTnC8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772480924; c=relaxed/simple; bh=M9hid6mLoVjX0NArwVDhcI7KKPwC1u1WyaIZGAwE6hk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mMTRD5ZmyPVjivAFx0rwLLeFTA5sgZuOvWGwtO4HcG0jD9gHFo0XDOSMory9aDDePylBsoQasGtFzRktx+JXUO2UPSlPjC3RsxB4u+nDSGVvD5mj9Ukb+2YuR8ndf7rV8d4YT08gGr5FOiolgdLRr1lpjzSx5cwqJ9Pw9dnc9Oo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=mgBbJJ1E; arc=none smtp.client-ip=209.85.167.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mgBbJJ1E" Received: by mail-oi1-f169.google.com with SMTP id 5614622812f47-464ba2bb3aeso3840369b6e.1 for ; Mon, 02 Mar 2026 11:48:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772480918; x=1773085718; darn=vger.kernel.org; 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=Puy9yrqJbk0e9aaEAb6IkFimwFJOtZJS6lRexavpIMI=; b=mgBbJJ1EwpOnui/rrgri+0srtjf1mX0/2CKR4rOU9ekZzI4i452gOi3hQnzzrNKXdG B3cNjGelz3ZFRBn701IV64k0Wv9hqlh/5BCSJ92zz2LwnPub63hTBIB1dSEQZfti8ms2 94U1+q+1vHEnQ1Vy2sBeDxLV+LC+Ibf3niAihFzn3/5BSWGOa2lR6KVPJtwtn+DtOgAK MTHLo/pn/GGlD7emaWOydJDWWYvw5ZHcpMY66gxtM4oCZIn/t4MGtn0hiM/Te+XZ2UBQ 0Oih6cNBDPh2ft+B6upO/lPfDWIc9HZPKgA3aQAxIw91Lv+SUyqdGucLPkdEKwusRvtL 7kww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772480918; x=1773085718; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Puy9yrqJbk0e9aaEAb6IkFimwFJOtZJS6lRexavpIMI=; b=IpqCddPoHSUtPq2naQwbpK4/wUxFdptbnpE+ntHTjJodDGXDyU8fjH1Sz04Y72Tdax hkWFfkmyKHEWCTT7e6uwgZxMpWkOmoUupGar7wV9Hhfkh6QeaUFHREorpal1R0I7CaKV kcmPAq6hZ+cQDInpWyXyD6lJ1qJBQQYXDLEnoFOKDW3eoD711+X9a9kgmKuyG1ssrlOs 6zMSvGFNOsQ9bQkZiiAoyt8xXB09L3rIsrg92pzxLNVsH69epqemP6U9+DJ6kWP6mMIn 36JijdwertfekRFy11zso6yvJzwPr0Of3TTwCoNkrN6a8Zs0q+at7wM+e8HkkpF9nb7Z 0uXA== X-Forwarded-Encrypted: i=1; AJvYcCXGYj8BiIpcF9sD63wKHutVLZkbipgm/L0bQKz9CGZNu2iN+8JgiaFFJRRD+/Y478QSDQy1HgRRRWAwMX8=@vger.kernel.org X-Gm-Message-State: AOJu0YxUSNoUPUkqoQZ0A/0z/Mug4fV4RhGpkMzAJCWmlnwMHl1RU4AT wWdHW8qMpge/NSZCi80QchJ2oVFzpZ93qpMhjTRHaLkKGPYWhLfw8TYLivTWTw== X-Gm-Gg: ATEYQzwoIkDMV5TeTI4xonIkOsRkpzYDhz3zmMBVF3PqbuWnFvzxBXNLkFmFdPzhpfH qaQ9gjWsPDeStPJwSN3aQH6DVMN3lOHUATj+0WAEw+ReXl9PbrTgethT++/DCFRPx1ZwrJ7DY2C SPi9Up4QSsEciN+QM1dae/YzpeQIrqIUxL2NHZpAFbzGK7oKwtTWKvVD52e9h6wC72yrO7Cmm5f yjWohCkp4/SWIk7AEhvhQn64+MIlP5H3sV4uYU6Te7Jjx5xx2dG1f7uA7XcLDOB9Qn7cVSa+/1a pz1tXhX2jZz4QuFwy79yxCQyz4slwynkAtD6pTWhHvuZ157eX0/OD5GBCdUBI1MyHRygpu/dARW 5jSP5J2EHc2XNtZH9VLB7rEZ+8Ip5IzkYOAI1ld8LktWkN6Plw9YJtfNBepu3wbeQfD7BN8gmjs fSbhRzVhcAVL5gp7e+SCEOAQ== X-Received: by 2002:a05:6808:6601:b0:450:b87b:1ec4 with SMTP id 5614622812f47-464bef0f899mr7178418b6e.15.1772480918630; Mon, 02 Mar 2026 11:48:38 -0800 (PST) Received: from localhost ([2a03:2880:10ff:56::]) by smtp.gmail.com with ESMTPSA id 5614622812f47-464bb5da37csm8384121b6e.17.2026.03.02.11.48.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Mar 2026 11:48:38 -0800 (PST) From: Joshua Hahn To: Alexey Suchkov Cc: akpm@linux-foundation.org, dywoq.contact@gmail.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH] [PATCH v2] mm: initialize 'seq' in gup_fast to remove -Wmaybe-uninitialized warning Date: Mon, 2 Mar 2026 11:48:35 -0800 Message-ID: <20260302194836.2932150-1-joshua.hahnjy@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260302193405.37961-1-dywoq.contact@gmail.com> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Mon, 2 Mar 2026 22:34:05 +0300 Alexey Suchkov wrote: > The local variable 'seq' in gup_fast (mm/gup.c) was declared > without initialization, which can trigger: > > mm/gup.c:3165:20: warning: ‘seq’ may be used uninitialized [-Wmaybe-uninitialized] > > Initialize 'seq' to 0. This does not change behavior, since > read_seqcount_retry() always writes to it before use. Hi Alexey, I hope you're doing well! Unfortunately I think that this patch is still unneeded. The variable seq is used in two places, raw_seqcount_try_begin and read_seqcount_retry, and nowhere else in the function. Both are guarded by if (gup_flags & FOLL_PIN). raw_seqcount_try_begin is a macro that sets the value of seq. read_seqcount_retry is a macro that indeed reads the value of seq, but at that point seq has already been initialized by raw_seqcount_try_begin. So I am having a hard time seeing where it would ever be used in an uninitialized context. The compiler should be smart enough to expand the macro, see that the writer and consumer are under the same if conditions, and realize that it is always initialized before being used. I'm curious to know if the compilation warning above is theoretical, or if you've actually it it during compilation. Let me know what you think. Have a great day! Joshua > Changes since v1: > - Removes the accidental formatting from v1. > > Signed-off-by: Alexey Suchkov > --- > mm/gup.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/gup.c b/mm/gup.c > index 8e7dc2c6e..879798de5 100644 > --- a/mm/gup.c > +++ b/mm/gup.c > @@ -3131,7 +3131,7 @@ static unsigned long gup_fast(unsigned long start, unsigned long end, > { > unsigned long flags; > int nr_pinned = 0; > - unsigned seq; > + unsigned int seq = 0; > > if (!IS_ENABLED(CONFIG_HAVE_GUP_FAST) || > !gup_fast_permitted(start, end)) > -- > 2.53.0