Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1533623

Re: [PATCH] intelrdt: resctrl: recommend locking for resctrlfs

From Fenghua Yu <fenghua.yu@intel.com>
Newsgroups linux.kernel
Subject Re: [PATCH] intelrdt: resctrl: recommend locking for resctrlfs
Date 2016-11-30 23:10 +0100
Message-ID <sJleG-3nG-25@gated-at.bofh.it> (permalink)
References <sJfiV-7Va-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wed, Nov 30, 2016 at 01:48:10PM -0200, Marcelo Tosatti wrote:
> 
> 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

This is one example of why locking is needed. There are other scenarios
that need the locking as well. For example, two applications scan each
directory to find an empty/less loaded "tasks". Both of them find that
directory p1 has empty "tasks" and write their own thread ids into the
"tasks" in p1. Turns out the "tasks" in p1 will have crowded threads or
workloads. A locking can solve this race scenario too.

As a user interface document, maybe we need a generic explanation why
locking plus the example.

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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] intelrdt: resctrl: recommend locking for resctrlfs  Marcelo Tosatti <mtosatti@redhat.com> - 2016-11-30 16:50 +0100
  Re: [PATCH] intelrdt: resctrl: recommend locking for resctrlfs  Thomas Gleixner <tglx@linutronix.de> - 2016-11-30 22:20 +0100
  Re: [PATCH] intelrdt: resctrl: recommend locking for resctrlfs Fenghua Yu <fenghua.yu@intel.com> - 2016-11-30 23:10 +0100
    Re: [PATCH] intelrdt: resctrl: recommend locking for resctrlfs Marcelo Tosatti <mtosatti@redhat.com> - 2016-12-01 14:00 +0100
      Re: [PATCH] intelrdt: resctrl: recommend locking for resctrlfs Fenghua Yu <fenghua.yu@intel.com> - 2016-12-01 23:00 +0100
    [PATCH v2] intelrdt: resctrl: recommend locking for resctrlfs  Marcelo Tosatti <mtosatti@redhat.com> - 2016-12-02 12:00 +0100
      Re: [PATCH v2] intelrdt: resctrl: recommend locking for resctrlfs  Thomas Gleixner <tglx@linutronix.de> - 2016-12-02 12:30 +0100
        Re: [PATCH v2] intelrdt: resctrl: recommend locking for resctrlfs Marcelo Tosatti <mtosatti@redhat.com> - 2016-12-02 23:10 +0100
          Re: [PATCH v2] intelrdt: resctrl: recommend locking for resctrlfs Thomas Gleixner <tglx@linutronix.de> - 2016-12-09 10:40 +0100

csiph-web