public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Paris <eparis@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: Eric Paris <eparis@redhat.com>,
	Andreas Schwab <schwab@redhat.com>,
	Tvrtko Ursulin <tvrtko.ursulin@sophos.com>,
	Andreas Gruenbacher <agruen@suse.de>
Subject: [PATCH -v2] fanotify: drops the packed attribute from userspace event metadata
Date: Tue, 24 Aug 2010 16:43:02 -0400	[thread overview]
Message-ID: <1282682582-15980-1-git-send-email-eparis@redhat.com> (raw)

The userspace event metadata structure was packed so when sent from a kernel
with a certain set of alignment rules to a userspace listener with a different
set of alignment rules the userspace process would be able to use the
structure.  On some arches just using packed, even if it doesn't do anything
to the alignment can cause a severe performance hit.  From now on we are
not going to set the packed attribute and will just need to be very careful
to make sure the structure is naturally aligned.

Cc: Andreas Schwab <schwab@redhat.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@sophos.com>
Cc: Andreas Gruenbacher <agruen@suse.de>
Signed-off-by: Eric Paris <eparis@redhat.com>
---
 include/linux/fanotify.h |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/include/linux/fanotify.h b/include/linux/fanotify.h
index 0535461..b892e46 100644
--- a/include/linux/fanotify.h
+++ b/include/linux/fanotify.h
@@ -65,20 +65,23 @@
 				 FAN_ALL_PERM_EVENTS |\
 				 FAN_Q_OVERFLOW)
 
-#define FANOTIFY_METADATA_VERSION	1
-
+#define FANOTIFY_METADATA_VERSION	2
+/*
+ * These structures must be naturally aligned so that a 32 bit userspace process
+ * will find the offsets the same as a 64bit process.
+ */
 struct fanotify_event_metadata {
 	__u32 event_len;
 	__u32 vers;
-	__u64 mask;
+	aligned_u64 mask;
 	__s32 fd;
 	__s32 pid;
-} __attribute__ ((packed));
+};
 
 struct fanotify_response {
 	__s32 fd;
 	__u32 response;
-} __attribute__ ((packed));
+};
 
 /* Legit userspace responses to a _PERM event */
 #define FAN_ALLOW	0x01
-- 
1.7.1


             reply	other threads:[~2010-08-24 20:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-24 20:43 Eric Paris [this message]
2010-08-27 23:51 ` [PATCH -v2] fanotify: drops the packed attribute from userspace event metadata Eric Paris
2010-08-30  1:26   ` aligned_{u64,be64,le64} defined in #ifdef __KERNEL__ Andreas Gruenbacher
2010-08-30  4:21     ` David Miller
2010-08-30 10:58       ` Andreas Gruenbacher
2010-08-30 13:02         ` Jan Engelhardt
2010-08-31  1:42           ` David Miller
2010-10-06  6:05           ` Jan Engelhardt
2010-10-06  6:10             ` David Miller
2010-12-13 22:04               ` Iain Paton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1282682582-15980-1-git-send-email-eparis@redhat.com \
    --to=eparis@redhat.com \
    --cc=agruen@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=schwab@redhat.com \
    --cc=tvrtko.ursulin@sophos.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox