From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 2F6B732142A for ; Wed, 31 Dec 2025 12:21:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767183688; cv=none; b=pX5EIr/vrGiyI2C5I8Ujqnw/hW5LyWDOraNNGCh+DGWBO1TkFNFip4/WPeevXHW8N3mceTEmxuzLwWuNaejxkWmioZTdKxYDiv7GchNhbLY9mnOggcp6ktxxlJFQjYE8bIH949Nq28jnL6PzatQazfpXSgN1/fPJHf+jGq08hgY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767183688; c=relaxed/simple; bh=AM66Jf+D9UUsJYm+XOQXEqT8AT7ronksz3nQwnJvFRg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dAasp784RjNNfApPMmbDC8vGOPNEpARyek5v2XEGITF3UPg6N5+veHzsA0d0ER7xoOwJkQ2Pv7rrcUJkqrRBCZ+nnkGnsTNH6shyCFxb1/YsFBADYULP/sFKT9Zv3C+F23nar83iglfVdxyDcVzs6Mj0yzq96HpGKrjAkZCYorQ= 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=bf+PeeI7; arc=none smtp.client-ip=209.85.214.180 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="bf+PeeI7" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2a1022dda33so88350795ad.2 for ; Wed, 31 Dec 2025 04:21:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767183683; x=1767788483; 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=l1zQ6x4JBvnjcii6rxQIcqW7gW9Zy85sg7DcmNPmmRU=; b=bf+PeeI7bRmKRe65CsCRH5P983lJvFBSTwokFXWsOXy5jfzwIgjcI94NvFYNRggF3c 2Nrj6oTIrsQwncghiHmJ73aSsc8ui1GZZqAvb9L+bCgTV6EOGtUWUzGMrxZijSu81v6g uJBLmxdZAKNA0eg7OzNAl/dUeeI3IOl+DRZ6ZmSu19O4T6w4KTMVxLa7jJdAoYJHJEAf 9C4PrXNIAxyWxCrA3En3BMvHgraFEAjq1xQloA1kPKciYhJ7qxZtdXVpEroJ6POubQ0G vqZldSdkjhF/9HS/FCMLfgKCbTJCfl5FlXwzBlQvTePSn+Wm4bzuwKwafMlURihWUEFo lkqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767183683; x=1767788483; 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=l1zQ6x4JBvnjcii6rxQIcqW7gW9Zy85sg7DcmNPmmRU=; b=icB83WDrboUGzFEPgnxxAOzYn5OBrwXUmxru9nM4UTKrOfkPTl75Y+NLc65/L0qGVF zHgOk1490g2h5N3m17NKw3KTFDg3ntOyLCBpHYQgzF3AhSGZwj16nfMMnZ8Nl1Ne1GuY Ondx+0WypP7XnxRlqA5Q5pI38P6C/Rz61A+oQklWq/eWjiHZFmWe0kQWI7pVNdPnV/5q bai71JvwDw8KAVvuXuUP/i/3Ckusa0cRCftYukGkzOURst7AXC7/VILZ3j0SHJJ63jfN hA/qiMhKqzpFpfYHy1SWdbNmuQjIJ4ndN5KY1XObZnWVG205ELt4PdPTq38y0UASMpn2 QR1Q== X-Forwarded-Encrypted: i=1; AJvYcCXTnJn7J7iBAyMZPeXq3o92bYJFvRPUR+7rbijWYyg5WTZgyfER5vRq7LXnC+oTctdOM9BmIPHUbB2q5Xs=@vger.kernel.org X-Gm-Message-State: AOJu0YzWMtML4NPn1AO6Xw2UGEwYMks7fbcB2VkMyM3hgDb5/w0cIRFB Iwg6SacCWREfy7mJD+WFB+3myEiJsM9XKRFCY8jT0C/7UOq14SqPHbm/ X-Gm-Gg: AY/fxX54Sgh+77ZbE5POguegAOqTcys9pqHqmc8qK2x6TjCHcZBDR6iZ0h+VPmcuX2R zmWd3VR0A7HJzzAGbkVMy0k0tqqWnN8M9kOlpbJEjt+/heO0PSpve9ShAcN7XHezKxcmSv6Cy8L 5Qknx8lt87qMKj8l3lBSWGkACq8wQPM/cmyaz+zBgQfBydI7ySa3G598EgvJLroSTsrcFpPIfWG t7QNN9zKZstgxJpgTlmn9wrGRcTahzhtjW6nrO2lle/MJiO2HbhpE5MxFgjII5F9yH53nV0l1cq ulmXffovBs961vsVmzTwVQW3xz5PN4PUulSz6Nc1m9E7IVZzcm9ZihfZd7c0qosWdVPPQbKqlrc bIm7zWkk3d0Ni8z5QrKO0Oo4sWbEIgDAOF/nZ+eXKBOWqXhT2oXbM1qdebS5GCYWFoE2xxaHQLf qy2qRhgso= X-Google-Smtp-Source: AGHT+IG3HnaH+f6fsjU47HQdlXrZ7oQYX/xrU6Ub7MM9YQXarksQ4+8UuW9vEeF2U1f5e5gUpCwR+Q== X-Received: by 2002:a17:902:d54b:b0:2a2:d2e8:9f25 with SMTP id d9443c01a7336-2a2f28368eamr365848575ad.33.1767183683334; Wed, 31 Dec 2025 04:21:23 -0800 (PST) Received: from ubuntu.. ([103.163.65.25]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-34e70dccd14sm35760786a91.16.2025.12.31.04.21.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Dec 2025 04:21:23 -0800 (PST) From: Dipendra Khadka To: akpm@linux-foundation.org Cc: kdipendra88@gmail.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, mhocko@suse.com, rientjes@google.com, shakeel.butt@linux.dev Subject: Re: [PATCH] mm/oom_kill: Remove unnecessary integer promotion in format string Date: Wed, 31 Dec 2025 12:21:17 +0000 Message-ID: <20251231122117.7683-1-kdipendra88@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251230123336.ef33f8a55df71f3e3f782532@linux-foundation.org> References: <20251230123336.ef33f8a55df71f3e3f782532@linux-foundation.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit >It's a teeny issue but I do like the present code - be very explicit >and careful about the types we're dealing with, don't rely on unobvious >C rules. Actually, the scenario here is that while printing a short, it is **promoted** to int due to C's variadic argument promotion rules. Yes, we must use %hd when the **semantic type** is short. However, due to integer promotion, the value is already passed as a 4-byte int on the stack. The %hd format specifier then casts it back to short for display. Since the value is already promoted to int internally, using %d is simpler and avoids the unnecessary cast. The checkpatch warning confirms this: ``` WARNING: Integer promotion: Using 'h' in '%hd' is unnecessary #461: FILE: mm/oom_kill.c:461: + pr_warn("%s invoked oom-killer: gfp_mask=%#x(%pGg), order=%d, oom_score_adj=%hd\n", + current->comm, oc->gfp_mask, &oc->gfp_mask, oc->order, + current->signal->oom_score_adj); WARNING: Integer promotion: Using 'h' in '%hd' is unnecessary #961: FILE: mm/oom_kill.c:961: + pr_err("%s: Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB, shmem-rss:%lukB, UID:%u pgtables:%lukB oom_score_adj:%hd\n", + message, task_pid_nr(victim), victim->comm, K(mm->total_vm), + K(get_mm_counter(mm, MM_ANONPAGES)), + K(get_mm_counter(mm, MM_FILEPAGES)), + K(get_mm_counter(mm, MM_SHMEMPAGES)), + from_kuid(&init_user_ns, task_uid(victim)), + mm_pgtables_bytes(mm) >> 10, victim->signal->oom_score_adj); ``` Checkpatch flags the 'h' modifier as unnecessary for this reason, and many other subsystems have moved to using %d for promoted types. Hence, I think this patch aligns with kernel coding practices. Best Rgards, Dipendra Khadka