lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZyJDSqlB_U_z7V74@google.com>
Date: Wed, 30 Oct 2024 07:31:38 -0700
From: Sean Christopherson <seanjc@...gle.com>
To: Ackerley Tng <ackerleytng@...gle.com>
Cc: muchun.song@...ux.dev, peterx@...hat.com, akpm@...ux-foundation.org, 
	rientjes@...gle.com, fvdl@...gle.com, jthoughton@...gle.com, david@...hat.com, 
	isaku.yamahata@...el.com, zhiquan1.li@...el.com, fan.du@...el.com, 
	jun.miao@...el.com, tabba@...gle.com, quic_eberman@...cinc.com, 
	roypat@...zon.co.uk, jgg@...dia.com, jhubbard@...dia.com, pbonzini@...hat.com, 
	erdemaktas@...gle.com, vannapurve@...gle.com, pgonda@...gle.com, 
	linux-kernel@...r.kernel.org, linux-mm@...ck.org
Subject: Re: [RFC PATCH 1/3] mm: hugetlb: Simplify logic in dequeue_hugetlb_folio_vma()

On Fri, Oct 11, 2024, Ackerley Tng wrote:
> Replace arguments avoid_reserve and chg in dequeue_hugetlb_folio_vma()
> so dequeue_hugetlb_folio_vma() is more understandable.
> 
> The new argument, use_hstate_resv, indicates whether the folio to be
> dequeued should be taken from reservations in hstate.
> 
> If use_hstate_resv is true, the folio to be dequeued should be taken
> from reservations in hstate and hence h->resv_huge_pages is
> decremented, and the folio is marked so that the reservation is
> restored.
> 
> If use_hstate_resv is false, then a folio needs to be taken from the
> pool and hence there must exist available_huge_pages(h), failing
> which, goto err.
> 
> The bool use_hstate_resv can be reused within
> dequeue_hugetlb_folio_vma()'s caller, alloc_hugetlb_folio().
> 
> No functional changes are intended.
> 
> As proof, the original two if conditions
> 
> !vma_has_reserves(vma, chg) && !available_huge_pages(h)
> 
> and
> 
> avoid_reserve && !available_huge_pages(h)
> 
> can be combined into
> 
> (avoid_reserve || !vma_has_reserves(vma, chg))
> && !available_huge_pages(h).

The period here, and the comma later, are weird.

> Applying de Morgan's theorem on
> 
> avoid_reserve || !vma_has_reserves(vma, chg)
> 
> yields
> 
> !avoid_reserve && vma_has_reserves(vma, chg),
> 
> hence the simplification is correct.

Whitespace exists for a reason :-)

---

As proof, the original two if conditions

  !vma_has_reserves(vma, chg) && !available_huge_pages(h)

and

  avoid_reserve && !available_huge_pages(h)

can be combined into

  (avoid_reserve || !vma_has_reserves(vma, chg)) && !available_huge_pages(h)

Applying de Morgan's theorem on

  avoid_reserve || !vma_has_reserves(vma, chg)

yields

  !avoid_reserve && vma_has_reserves(vma, chg)

hence the simplification is correct.

---

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ