Re: [PATCH 1/8] samples: move accounting example code from Documentation

2016-09-20 Thread Shuah Khan
On 09/19/2016 10:02 AM, Jonathan Corbet wrote:
> On Mon, 19 Sep 2016 08:47:32 -0600
> Shuah Khan  wrote:
> 
>> Move accounting examples to samples and remove it from Documentation
>> Makefile. Create a new Makefile to build accounting. It can be built
>> from top level directory or from accounting directory:
> 
> So I like the basic idea of these patches; it's the direction we've been
> trying to push things for a little bit.  I have a couple of specific
> comments for this one that may well apply to the others as well.
> 
> 1) Is samples the right destination for these utilities?  Some of them
>might well be better placed under tools/ instead.  I'm not sure we've
>ever formally stated the purpose of those two subtrees; I see samples/
>as demonstrations of how to use something, while tools/ are utilities
>you might actually want to use for some purpose.  Something like
>getdelays might well fall into the latter group.  But maybe others
>disagree?

getdelays stumped me a bit. My first choice was tools and then I noticed
that the documentation says it is a tool and an example usage of taskstruct.
I am not set on tools or samples as location for this. I can move it to
tools instead.

> 
> 2) Tools like getdelays are referenced in the documents that have been
>left behind; see accounting/delay-accounting.txt, for example.  Those
>documents should be updated so that readers know where to find the
>referenced programs, wherever they end up.  Converting them to Sphinx
>while you're at it is an extra-credit exercise :)

Right. Documents need updates and also the 00-Index files. I agree with
you that converting to Sphinx makes sense. There will be some learning
curve on my part. I can take this one once the move happens and do the
Documentation and 00-Index file updates.

thanks,
-- Shuah

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH 1/8] samples: move accounting example code from Documentation

2016-09-19 Thread Jonathan Corbet
On Mon, 19 Sep 2016 08:47:32 -0600
Shuah Khan  wrote:

> Move accounting examples to samples and remove it from Documentation
> Makefile. Create a new Makefile to build accounting. It can be built
> from top level directory or from accounting directory:

So I like the basic idea of these patches; it's the direction we've been
trying to push things for a little bit.  I have a couple of specific
comments for this one that may well apply to the others as well.

1) Is samples the right destination for these utilities?  Some of them
   might well be better placed under tools/ instead.  I'm not sure we've
   ever formally stated the purpose of those two subtrees; I see samples/
   as demonstrations of how to use something, while tools/ are utilities
   you might actually want to use for some purpose.  Something like
   getdelays might well fall into the latter group.  But maybe others
   disagree?

2) Tools like getdelays are referenced in the documents that have been
   left behind; see accounting/delay-accounting.txt, for example.  Those
   documents should be updated so that readers know where to find the
   referenced programs, wherever they end up.  Converting them to Sphinx
   while you're at it is an extra-credit exercise :)

Thanks,

jon

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


[PATCH 1/8] samples: move accounting example code from Documentation

2016-09-19 Thread Shuah Khan
Move accounting examples to samples and remove it from Documentation
Makefile. Create a new Makefile to build accounting. It can be built
from top level directory or from accounting directory:

Run make -C samples/accounting or cd samples/accounting; make

Signed-off-by: Shuah Khan 
---
 Documentation/Makefile   |   2 +-
 Documentation/accounting/.gitignore  |   1 -
 Documentation/accounting/Makefile|   7 -
 Documentation/accounting/getdelays.c | 550 ---
 samples/accounting/.gitignore|   1 +
 samples/accounting/Makefile  |   9 +
 samples/accounting/getdelays.c   | 550 +++
 7 files changed, 561 insertions(+), 559 deletions(-)
 delete mode 100644 Documentation/accounting/.gitignore
 delete mode 100644 Documentation/accounting/Makefile
 delete mode 100644 Documentation/accounting/getdelays.c
 create mode 100644 samples/accounting/.gitignore
 create mode 100644 samples/accounting/Makefile
 create mode 100644 samples/accounting/getdelays.c

diff --git a/Documentation/Makefile b/Documentation/Makefile
index f530c29..58c6629 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -1,2 +1,2 @@
-subdir-y := accounting auxdisplay blackfin \
+subdir-y := auxdisplay blackfin \
laptops mic misc-devices pcmcia timers watchdog
diff --git a/Documentation/accounting/.gitignore 
b/Documentation/accounting/.gitignore
deleted file mode 100644
index 8648520..000
--- a/Documentation/accounting/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-getdelays
diff --git a/Documentation/accounting/Makefile 
b/Documentation/accounting/Makefile
deleted file mode 100644
index 7e232cb..000
--- a/Documentation/accounting/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-# List of programs to build
-hostprogs-y := getdelays
-
-# Tell kbuild to always build the programs
-always := $(hostprogs-y)
-
-HOSTCFLAGS_getdelays.o += -I$(objtree)/usr/include
diff --git a/Documentation/accounting/getdelays.c 
b/Documentation/accounting/getdelays.c
deleted file mode 100644
index b5ca536..000
--- a/Documentation/accounting/getdelays.c
+++ /dev/null
@@ -1,550 +0,0 @@
-/* getdelays.c
- *
- * Utility to get per-pid and per-tgid delay accounting statistics
- * Also illustrates usage of the taskstats interface
- *
- * Copyright (C) Shailabh Nagar, IBM Corp. 2005
- * Copyright (C) Balbir Singh, IBM Corp. 2006
- * Copyright (c) Jay Lan, SGI. 2006
- *
- * Compile with
- * gcc -I/usr/src/linux/include getdelays.c -o getdelays
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-#include 
-#include 
-
-/*
- * Generic macros for dealing with netlink sockets. Might be duplicated
- * elsewhere. It is recommended that commercial grade applications use
- * libnl or libnetlink and use the interfaces provided by the library
- */
-#define GENLMSG_DATA(glh)  ((void *)(NLMSG_DATA(glh) + GENL_HDRLEN))
-#define GENLMSG_PAYLOAD(glh)   (NLMSG_PAYLOAD(glh, 0) - GENL_HDRLEN)
-#define NLA_DATA(na)   ((void *)((char*)(na) + NLA_HDRLEN))
-#define NLA_PAYLOAD(len)   (len - NLA_HDRLEN)
-
-#define err(code, fmt, arg...) \
-   do {\
-   fprintf(stderr, fmt, ##arg);\
-   exit(code); \
-   } while (0)
-
-int done;
-int rcvbufsz;
-char name[100];
-int dbg;
-int print_delays;
-int print_io_accounting;
-int print_task_context_switch_counts;
-
-#define PRINTF(fmt, arg...) {  \
-   if (dbg) {  \
-   printf(fmt, ##arg); \
-   }   \
-   }
-
-/* Maximum size of response requested or message sent */
-#define MAX_MSG_SIZE   1024
-/* Maximum number of cpus expected to be specified in a cpumask */
-#define MAX_CPUS   32
-
-struct msgtemplate {
-   struct nlmsghdr n;
-   struct genlmsghdr g;
-   char buf[MAX_MSG_SIZE];
-};
-
-char cpumask[100+6*MAX_CPUS];
-
-static void usage(void)
-{
-   fprintf(stderr, "getdelays [-dilv] [-w logfile] [-r bufsize] "
-   "[-m cpumask] [-t tgid] [-p pid]\n");
-   fprintf(stderr, "  -d: print delayacct stats\n");
-   fprintf(stderr, "  -i: print IO accounting (works only with -p)\n");
-   fprintf(stderr, "  -l: listen forever\n");
-   fprintf(stderr, "  -v: debug on\n");
-   fprintf(stderr, "  -C: container path\n");
-}
-
-/*
- * Create a raw netlink socket and bind
- */
-static int create_nl_socket(int protocol)
-{
-   int fd;
-   struct sockaddr_nl local;
-
-   fd = socket(AF_NETLINK, SOCK_RAW, protocol);
-   if (fd < 0)
-   return -1;
-
-   if (rcvbufsz)
-   if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF,
-   , sizeof(rcvbufsz)) < 0) {
-