Re: [dhowells-fs:afs-next] BUILD REGRESSION 0c4555b845cdb41cc48a5831ec7c8d08df686062

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Apr 02, 2018 at 11:46:49AM +0800, Fengguang Wu wrote:
> Looks like we can CC this to the sparse list.  -fengguang
> 
> On Sat, Mar 31, 2018 at 11:23:23AM +0100, David Howells wrote:
> > kbuild test robot <fengguang.wu@xxxxxxxxx> wrote:
> > 
> > > fs/afs/dynroot.c:114:38: sparse: context imbalance in 'afs_lookup_atcell' - different lock contexts for basic block
> > > fs/afs/proc.c:353:38: sparse: context imbalance in 'afs_proc_rootcell_read' - different lock contexts for basic block
> > 
> > sparse doesn't seem to understand how read_seqbegin_or_lock() works.  The
> > following construct confuses it:
> > 
> > 	unsigned int seq = 0;
> > 	...
> > 	do {
> > 		read_seqbegin_or_lock(&lock, &seq);
> > 		/* ... access locked variables ... */
> > 	} while (need_seqretry(&lock, seq));
> > 	done_seqretry(&lock, seq);
> > 
> > because the actual start of the lock is the seq = 0.  read_seqbegin_or_lock()
> > has to be passed through twice if you find you actually need the lock and this
> > confuses sparse's count.
> > 
> > David


Hi,

I haven't looked closely to this but here is some information about
how sparse's lock context is working (this really should somehow be
added to Documention/dev-tools/sparse.rst).


  Sparse's goal regarding the context imbalance is to give a warning
  if some code can be reached via two or more paths and the lock state
  (the context) is not identical in each of these paths. For example, any
  function doing conditional locking is concerned, almost by definition.
  A typical example is code like:

	if (some_test)
		lock_xyz();

	do_stuff();

	if (some_test)
		unlock_xyz();

  It's clear, when reading the code, that the result of 'some_test'
  is not supposed to change, but very often it's not possible to
  guarantee this or sparse is not smart enough to see it.
  It should be noted, that in the general case, this is equivalent
  to the halting problem and similar problems.

Best regards,
-- Luc Van Oostenryck
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux