pahole: Implement --packed

To show just packed structs.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
diff --git a/man-pages/pahole.1 b/man-pages/pahole.1
index 2e51569..cacdc58 100644
--- a/man-pages/pahole.1
+++ b/man-pages/pahole.1
@@ -295,6 +295,11 @@
 combine --structs with --sizes, etc.
 
 .TP
+.B \-\-packed
+Show only packed structs, all the other filters apply, i.e. to show just the
+sizes of all packed structs combine --packed with --sizes, etc.
+
+.TP
 .B \-\-unions
 Show only unions, all the other filters apply, i.e. to show just the sizes of all unions
 combine --union with --sizes, etc.
diff --git a/pahole.c b/pahole.c
index dac7a49..a041f4d 100644
--- a/pahole.c
+++ b/pahole.c
@@ -59,6 +59,7 @@
 static bool defined_in;
 static bool just_unions;
 static bool just_structs;
+static bool just_packed_structs;
 static int show_reorg_steps;
 static const char *class_name;
 static LIST_HEAD(class_names);
@@ -371,6 +372,12 @@
 	if (just_structs && !tag__is_struct(tag))
 		return NULL;
 
+	if (just_packed_structs) {
+		/* Is it not packed? */
+		if (!class__infer_packed_attributes(class, cu))
+			return NULL;
+	}
+
 	if (!tag->top_level) {
 		class__find_holes(class);
 
@@ -812,6 +819,7 @@
 #define ARGP_range		   316
 #define ARGP_skip_encoding_btf_vars 317
 #define ARGP_btf_encode_force	   318
+#define ARGP_just_packed_structs   319
 
 static const struct argp_option pahole__options[] = {
 	{
@@ -1111,6 +1119,11 @@
 		.doc  = "Show just unions",
 	},
 	{
+		.name = "packed",
+		.key  = ARGP_just_packed_structs,
+		.doc  = "Show just packed structs",
+	},
+	{
 		.name = NULL,
 	}
 };
@@ -1202,6 +1215,9 @@
 		just_unions = true;			break;
 	case ARGP_just_structs:
 		just_structs = true;			break;
+	case ARGP_just_packed_structs:
+		just_structs = true;
+		just_packed_structs = true;		break;
 	case ARGP_count:
 		conf.count = atoi(arg);			break;
 	case ARGP_skip: