linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] intelrdt: resctrl: recommend locking for resctrlfs
@ 2016-11-30 15:48 Marcelo Tosatti
  2016-11-30 21:10 ` Thomas Gleixner
  2016-11-30 22:05 ` Fenghua Yu
  0 siblings, 2 replies; 11+ messages in thread
From: Marcelo Tosatti @ 2016-11-30 15:48 UTC (permalink / raw)
  To: Yu, Fenghua, Thomas Gleixner; +Cc: linux-kernel


There is a locking problem between different applications
reading/writing to resctrlfs directory at the same time (read the patch
below for details).

Suggest a standard locking scheme for applications to use.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

--- Documentation/x86/intel_rdt_ui.txt.orig	2016-11-30 13:40:33.080233101 -0200
+++ Documentation/x86/intel_rdt_ui.txt	2016-11-30 13:45:01.253703259 -0200
@@ -212,3 +212,30 @@ Finally we move core 4-7 over to the new
 kernel and the tasks running there get 50% of the cache.
 
 # echo C0 > p0/cpus
+
+4) Locking between applications
+
+The allocation of an exclusive reservation
+of L3 cache involves:
+
+        1. read list of cbmmasks for each directory
+        2. find a contiguous set of bits in the global CBM bitmask
+          that is clear in any of the directory cbmmasks
+        3. create a new directory
+        4. set the bits found in step 2 to the new directory "schemata"
+           file
+
+If two applications attempt to allocate space race with each other
+(if two processes execute the steps above in a interlocked fashion),
+they can end up using the same bits of CBMMASK, which renders the
+reservations non-exclusive but shared.
+
+To coordinate creation of reservations on resctrl and avoid the problem
+above, the following locking procedure is recommended:
+
+A) open /var/lock/resctrl/fs.lock with O_CREAT|O_EXCL.
+B) if success, write pid of program accessing the directory
+   structure to this file.
+C) read/write the directory structure.
+D) remove file.
+

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

end of thread, other threads:[~2016-12-15 13:49 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-30 15:48 [PATCH] intelrdt: resctrl: recommend locking for resctrlfs Marcelo Tosatti
2016-11-30 21:10 ` Thomas Gleixner
2016-11-30 22:05 ` Fenghua Yu
2016-11-30 22:25   ` Marcelo Tosatti
2016-12-01 21:54     ` Fenghua Yu
2016-12-01 14:55   ` [PATCH v2] " Marcelo Tosatti
2016-12-02 11:20     ` Thomas Gleixner
2016-12-02 22:07       ` Marcelo Tosatti
2016-12-09  9:35         ` Thomas Gleixner
2016-12-14 17:08       ` [PATCH v3] " Marcelo Tosatti
2016-12-15 13:49         ` [tip:x86/cache] Documentation, x86, resctrl: Recommend " tip-bot for Marcelo Tosatti

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