linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Matthew Cassell <mcassell411@gmail.com>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/util.c: Added page count to __vm_enough_memory failure warning
Date: Thu, 22 Feb 2024 17:31:33 +0100	[thread overview]
Message-ID: <31bade75-316c-4f3a-9325-1e347975f93c@redhat.com> (raw)
In-Reply-To: <CANiscBBhk+g267yYz8DhgU23gt0Ranak4VctxeG1-_tt_KkOag@mail.gmail.com>

On 22.02.24 17:24, Matthew Cassell wrote:
> Resending due to plain-text email issue that caused mailing list to get skipped.
> 
> Thank you for the feedback. I agree with you and would prefer to use
> bytes/kbytes. Here are the 2 concerns that led to me keeping it as
> pages:
> 
> 
> 1. Reduce the impact of the patch. Here is the call trace to reach the
> failure warning:
> 
> <… usual mmap() stuff …>
> mmap_region() -> security_enough_memory_mm() -> __vm_enough_memory()
> 
> Within mmap_region(), the length variable originally passed to mmap()
> gets right-shifted to get the page count. My first thought was to add
> an additional an additional argument to security_enough_memory_mm() of
> type unsigned long to keep that variable, but saw a handful of calls
> to it that would have to conform to the change. Not that I do not
> think this debug statement does not warrant that, I felt the less
> impact, the better.
> 
> 
> 2. Concerned about losing bits. When converting back to bytes I was
> worried about the loss of precision and printing that number back to
> users:
> 
> unsigned long bytes_failed = pages << (PAGE_SHIFT);
> 

In which scenario would you imagine that we lose precision? In other 
words, how would someone be able to create a VMA that is larger than 
what we can fit into an unsigned long in bytes?

I'd simply print "pages << PAGE_SHIFT" here and not worry about that :)

-- 
Cheers,

David / dhildenb



      reply	other threads:[~2024-02-22 16:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-21 16:02 Matthew Cassell
2024-02-22 12:18 ` David Hildenbrand
2024-02-22 16:11   ` Matt Cassell
2024-02-22 16:24   ` Matthew Cassell
2024-02-22 16:31     ` David Hildenbrand [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=31bade75-316c-4f3a-9325-1e347975f93c@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mcassell411@gmail.com \
    /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