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


Groups > linux.kernel > #1539219

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

From Thomas Gleixner <tglx@linutronix.de>
Newsgroups linux.kernel
Subject Re: [PATCH v2] intelrdt: resctrl: recommend locking for resctrlfs
Date 2016-12-09 10:40 +0100
Message-ID <sMpOO-1yx-7@gated-at.bofh.it> (permalink)
References <sJfiV-7Va-7@gated-at.bofh.it> <sJleG-3nG-25@gated-at.bofh.it> <sJTJn-2Mb-7@gated-at.bofh.it> <sJUcp-3bc-3@gated-at.bofh.it> <sK4bM-19N-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, 2 Dec 2016, Marcelo Tosatti wrote:
> Actually, using flock(2) allows one to use LOCK_SH for readers and 
> this allows consistent writer/reader behaviour (say, a reader
> won't see a partially written directory).

Indeed.

> So the procedure would be:
> 
>     /var/lock/resctrl/fs.lock created previously in the filesystem.
> 
> WRITE LOCK:
> 
> A) Take flock(EXCLUSIVE) on /var/lock/resctrl/fs.lock
> B) If success, write pid of the program to the file.
> C) read/write the directory structure.
> D) funlock
> 
> READ LOCK:
> 
> A) Take flock(SHARED) on /var/lock/resctrl/fs.lock
> B) If success read the directory structure.
> C) funlock
> 
> 
> How about that?

Looks sane. Adding a small example in C and [ba]sh would be nice.

Thanks,

	tglx

Back to linux.kernel | Previous | NextPrevious 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