linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Dipendra Khadka <kdipendra88@gmail.com>
Cc: 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 17:45:58 -0800	[thread overview]
Message-ID: <20251231174558.6a317049e8d08cc323ceca64@linux-foundation.org> (raw)
In-Reply-To: <20251231122117.7683-1-kdipendra88@gmail.com>

On Wed, 31 Dec 2025 12:21:17 +0000 Dipendra Khadka <kdipendra88@gmail.com> wrote:

> 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.

hm, OK, this code is pretty lonely.

hp2:/usr/src/linux-6.19-rc3> grep -r "%hd" . | wc -l
50

Consistency is good.


      reply	other threads:[~2026-01-01  1:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-28 15:44 Dipendra Khadka
2025-12-29  3:52 ` David Rientjes
2025-12-29  8:27 ` Michal Hocko
2025-12-30 20:33   ` Andrew Morton
2025-12-31 12:21     ` Dipendra Khadka
2026-01-01  1:45       ` Andrew Morton [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251231174558.6a317049e8d08cc323ceca64@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=kdipendra88@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=rientjes@google.com \
    --cc=shakeel.butt@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox