linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] hugetlb: Fix up filesystem quota accounting
@ 2007-10-24 13:23 Adam Litke
  2007-10-24 13:23 ` [PATCH 1/3] [FIX] hugetlb: Fix broken fs quota management Adam Litke
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Adam Litke @ 2007-10-24 13:23 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, Ken Chen, Andy Whitcroft


Hugetlbfs implements a quota system which can limit the amount of memory that
can be used by the filesystem.  Before allocating a new huge page for a file,
the quota is checked and debited.  The quota is then credited when truncating
the file.  I found a few bugs in the code for both MAP_PRIVATE and MAP_SHARED
mappings.  Before detailing the problems and my proposed solutions, we should
agree on a definition of quotas that properly addresses both private and shared
pages.  Since the purpose of quotas is to limit total memory consumption on a
per-filesystem basis, I argue that all pages allocated by the fs (private and
shared) should be charged against quota.

Private Mappings
================
The current code will debit quota for private pages sometimes, but will never
credit it.  At a minimum, this causes a leak in the quota accounting which
renders the accounting essentially useless as it is.  Shared pages have a one
to one mapping with a hugetlbfs file and are easy to account by debiting on
allocation and crediting on truncate.  Private pages are anonymous in nature
and have a many to one relationship with their hugetlbfs files (due to copy on
write).  Because private pages are not indexed by the mapping's radix tree,
thier quota cannot be credited at file truncation time.  Crediting must be done
when the page is unmapped and freed.

Shared Pages
============
I discovered an issue concerning the interaction between the MAP_SHARED
reservation system and quotas.  Since quota is not checked until page
instantiation, an over-quota mmap/reservation will initially succeed.  When
instantiating the first over-quota page, the program will receive SIGBUS.  This
is inconsistent since the reservation is supposed to be a guarantee.  The
solution is to debit the full amount of quota at reservation time and credit
the unused portion when the reservation is released.

This patch series brings quotas back in line by making the following
modifications:
 - Debit quota when allocating a COW page
 - Credit MAP_PRIVATE pages at unmap time
     (shared pages continue to be credited during truncation)
 - Debit entire amount of quota at shared mmap reservation time

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2007-10-25 14:55 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-24 13:23 [PATCH 0/3] hugetlb: Fix up filesystem quota accounting Adam Litke
2007-10-24 13:23 ` [PATCH 1/3] [FIX] hugetlb: Fix broken fs quota management Adam Litke
2007-10-24 18:43   ` Dave Hansen
2007-10-24 19:03     ` Adam Litke
2007-10-24 19:18       ` Dave Hansen
2007-10-24 19:21       ` Ken Chen
2007-10-24 20:02         ` Adam Litke
2007-10-24 22:12           ` Dave Hansen
2007-10-25  5:20             ` Ken Chen
2007-10-25 14:54               ` Adam Litke
2007-10-24 13:23 ` [PATCH 2/3] hugetlb: Allow bulk updating in hugetlb_*_quota() Adam Litke
2007-10-24 13:24 ` [PATCH 3/3] [PATCH] hugetlb: Enforce quotas during reservation for shared mappings Adam Litke
2007-10-24 19:07   ` Dave Hansen
2007-10-24 19:52     ` Adam Litke
2007-10-24 20:00       ` Dave Hansen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).