Skip to contentSkip to conversation

shmem: Are we accounting block right?

PATCH Hillf Danton 2 participants 2 messages Aug 5, 2016 – Aug 6, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi all

Currently in mainline we do block account if the flags parameter carries VM_NORESERVE.

But blocks should be accounted if reserved, as shown by the following diff.

Am I missing anything?

thanks
Hillf

mm/shmem.c +2 -2
@@ -168,7 +168,7 @@ static inline int shmem_reacct_size(unsi
  */
 static inline int shmem_acct_block(unsigned long flags, long pages)
 {
-	if (!(flags & VM_NORESERVE))
+	if (flags & VM_NORESERVE)
 		return 0;
 
 	return security_vm_enough_memory_mm(current->mm,
@@ -177,7 +177,7 @@ static inline int shmem_acct_block(unsig
 
 static inline void shmem_unacct_blocks(unsigned long flags, long pages)
 {
-	if (flags & VM_NORESERVE)
+	if (!(flags & VM_NORESERVE))
 		vm_unacct_memory(pages * VM_ACCT(PAGE_SIZE));
 }
 

--

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

maintainer
#1 lore raw
Quoted 4 lines · Hillf Danton

Hi all

Currently in mainline we do block account if the flags parameter carries VM_NORESERVE.

Yes. (VM_NORESERVE being set in tmpfs file flags, but usually not on SysV SHM and mmaps of /dev/zero.)

Quoted 3 lines

But blocks should be accounted if reserved, as shown by the following diff.

Blocks should be accounted one by one as they are instantiated (tmpfs), unless the total size was all reserved upfront (SHM).

Quoted 2 lines

Am I missing anything?

Apparently, but I'm not sure what. Maybe the comments above shmem_acct_size() and shmem_acct_block() will help.

Hugh

Quoted 16 lines

thanks
Hillf

mm/shmem.c +1 -1
@@ -168,7 +168,7 @@ static inline int shmem_reacct_size(unsi
  */
 static inline int shmem_acct_block(unsigned long flags, long pages)
 {
-	if (!(flags & VM_NORESERVE))
+	if (flags & VM_NORESERVE)
 		return 0;
 
 	return security_vm_enough_memory_mm(current->mm,

mm/shmem.c static inline int shmem_acct_block(unsig

Quoted 9 lines
mm/shmem.c +1 -2
@@ -177,7 +177,7 @@ static inline int shmem_acct_block(unsig
 
 static inline void shmem_unacct_blocks(unsigned long flags, long pages)
 {
-	if (flags & VM_NORESERVE)
+	if (!(flags & VM_NORESERVE))
 		vm_unacct_memory(pages * VM_ACCT(PAGE_SIZE));
 }
 
--

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