Work in Progress -- lockstat and lockmeter enhancements
Lee Schermerhorn <lee.schermerhorn@hp.com>

Note:  I am maintaining changes with quilt.  Patches reside under
./.patches, with quilt's patch control info under ./.pc.  The file
00-defs-build contains shell function wrappers and environment
variables for quilt commands.
These defs, along with this README+lts, can be removed at some
point when this work is completed or abandoned.

Building:

Can build with internal copy of lockmeter.h in ./include/linux
[default] or with the lockmeter.h in the kernel source tree of
the running OS--i.e., in /lib/modules/$(uname -r)/build/include
--or from any other location by overriding the LINUX_INC_ROOT
definition on the make command line.  See the Makefile.


Changes from lockstat 1.4.11, so far:

Patch:  lockstat+lts-mods-1.patch

Makefile enhancements: build, install, cscope, tarball

Shell wrapper to select kernel version appropriate lockstat command.
Note:  hope to weaken dependency of lockstat command on exact kernel
version.  But, may still need/want this capability.
	Only install lockstat shell wrapper if specified by
	USE_LOCKSTAT_SH Makefile variable.  Default is 'n'.

version.h for version stamping lockstat executable and tarball.

README enhancements -- much more to do vis a vis documentation.

Build cleanup for various platforms, releases:
+ add header includes to obtain correct function prototypes
  fixes faults on x86_64.
+ define __KERNGLUE__ for RHEL4 [2.6.9+] builds

Reorg:
+ move externs, macro defs to header: lockstat.h

Map/symbol handling:
+ enhance to allow use of /proc/kallsyms for access to module
  symbols.

---

Patch:  lockstat-split-lockmeter.h.patch
Depends on:  lockmeter-04-split-lockmeter.h.patch

Patch:  lockstat-split-lockmeter.h.patch
Depends on:  lockmeter-04-split-lockmeter.h.patch

In the kernel patches, I split <linux/lockmeter.h> into a externally
visible [i.e., to lockstat] API definition header--still lockmeter.h--
and a kernel internal header <linux/lockmeter-internal.h>.  This
didn't actually require any changes to lockstat, as I hadn't
removed the LSTAT_*_SIZE definitions from lockmeter.h yet.  However,
I did define a mask for extracting the lock type embedded in the
call site addresses to eliminate use of a "magic number".  Changed
lockstat.c to use this symbolic mask name.

---

Patch:
Depends on:  lockmeter-05-prepare-for-dynamic-sizing.patch

lockstat-prepare-for-dynamic-sizing.patch
Change lockstat to be independent of kernel's internal table
sizes.  Pass these table sizes in the /proc/lockmeter "user
request" structure and dynamically allocate the appropriately
sized data areas in lockstat.

	Eventually hope to allow dynamic sizing of these
	tables w/o reconfiguring kernel--e.g., from lockstat
	command options.

On-going whitespace and stylistic "cleanup".

---

Patch:  lockstat-verbose-and-version-options.patch

Rename "version" option to upper case 'V' and use lower case 'v'
for "verbose". [more common conventions, IMO]

Cleanup:  re-order optstr and cases to alphabetical order to make it
easier [for me] to keep track of which options are used.

Added vprint() function for verbosity enabled prints.
Changed some debugopt conditional printf()s to vprint()s.

Also added similar "die()" function for fatal error messages.
Modify some in-line fprintf()+exit() to use die();
Replace fatalx() usage with die(); remove fatalx();

Added vprint() and die() to lockstat.h, and changed getsetdata.c
and symbols.c to use die() instead of fprintf()+exit().  This
required including lockstat.h into symbols.c.  However, symbols
doesn't need all of the lockmeter definitions, so moved include
of <linux/lockmeter.h> to a new header, "getsetdata.h".  Moved
prototypes for get/set functions to this new header, and include
it from lockstat.c.

---

Patch:  lockstat-use-lstat_utsname.patch
Depends on:  lockmeter-08-private-utsname-struct.patch

At some point upstream, <linux/utsname.h> started including a bunch
of other junk.  This broke lockstat when building against the kernel
source tree headers.  I noticed this with 2.6.18-rc[56]-mm[12].
Wanting to retain the abilility to build against the running kernel's
build tree, I modified  lockmeter.h to define a private lstat_utsname
structure that matches the internal new_utsname.

Then, I modified lockstat to remove the include of <linux/utsname.h>
and use the lstat_utsname structure from lockmeter.h to access the
info contained in the user request header structure.

Currently, lockmeter.h is the only header that lockstat directly
includes from ".../include/linux".

---

Patch:  lockstat-rhel5ga-build-cleanup.patch
Depends on:  RHEL5/GA installation

<linux/config.h> doesn't exist in RHEL5 [and more recent kernels].
Removed include from lockstat.c.  Turns out it's no longer required
since the "prepare for dynamic sizing" patch, as we now get the
table sizes from the /proc/lockmeter interface, rather than from
the kernel config info.  Could/should fold this patch in with the
preparation patch above.
