All of lore.kernel.org
 help / color / mirror / Atom feed
From: KaiGai Kohei <kaigai@kaigai.gr.jp>
To: Stephen Smalley <sds@tycho.nsa.gov>
Cc: James Morris <jmorris@namei.org>,
	KaiGai Kohei <kaigai@ak.jp.nec.com>,
	selinux@tycho.nsa.gov, Paul Moore <paul.moore@hp.com>,
	Yuichi Nakamura <ynakam@hitachisoft.jp>,
	Eric Paris <eparis@parisplace.org>
Subject: Re: [PATCH] Improve SELinux performance when AVC misses.
Date: Wed, 03 Oct 2007 22:41:58 +0900	[thread overview]
Message-ID: <47039C26.1040903@kaigai.gr.jp> (raw)
In-Reply-To: <1191338915.6799.17.camel@moss-spartans.epoch.ncsc.mil>

>> --------
>> +#if EBITMAP_UNIT_SIZE == 64
>> +		n->maps[index] = map;
>> +#else
>>   		while (map) {
>>   			n->maps[index] = map & (-1UL);
>>   			map = map >> EBITMAP_UNIT_SIZE;
>>   			index++;
>>   		}
>> +#endif
>> --------

- snip -

>> [kaigai@masu ~]$ ./a.out
>> code       = ffffffffffffffff
>> code >> 16 = 0000ffffffffffff
>> code >> 63 = 0000000000000001
>> code >> 64 = ffffffffffffffff
>> code >> 65 = 7fffffffffffffff
>> [kaigai@masu ~]$ uname -m
>> x86_64
>>
>> I was suprised at. :-)
> 
> Me too.  But see:
> http://gcc.gnu.org/ml/gcc/2004-11/msg01133.html
> http://marc.info/?t=118688311400003&r=1&w=2

#if ... #endif block was removed in the previous patch.
I added a macro that shifts a variable by the width of unsigned long,
defined as follows:

   #define EBITMAP_SHIFT_UNIT_SIZE(x)			\
   	(((x) >> EBITMAP_UNIT_SIZE / 2) >> EBITMAP_UNIT_SIZE / 2)

[PATCH] kills warnings in Improve SELinux performance when AVC misses

This patch kills ugly warnings when the "Improve SELinux performance
when ACV misses" patch.

Signed-off-by: KaiGai Kohei <kaigai@ak.jp.nec.com>
---
  security/selinux/ss/ebitmap.c |   11 +++++------
  security/selinux/ss/ebitmap.h |    2 ++
  2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/security/selinux/ss/ebitmap.c b/security/selinux/ss/ebitmap.c
index ae44c0c..c1a6b22 100644
--- a/security/selinux/ss/ebitmap.c
+++ b/security/selinux/ss/ebitmap.c
@@ -193,7 +193,7 @@ int ebitmap_netlbl_import(struct ebitmap *ebmap,
  			e_sft = delta % EBITMAP_UNIT_SIZE;
  			while (map) {
  				e_iter->maps[e_idx++] |= map & (-1UL);
-				map >>= EBITMAP_UNIT_SIZE;
+				map = EBITMAP_SHIFT_UNIT_SIZE(map);
  			}
  		}
  		c_iter = c_iter->next;
@@ -389,13 +389,13 @@ int ebitmap_read(struct ebitmap *e, void *fp)

  		if (startbit & (mapunit - 1)) {
  			printk(KERN_ERR "security: ebitmap start bit (%d) is "
-			       "not a multiple of the map unit size (%Zd)\n",
+			       "not a multiple of the map unit size (%u)\n",
  			       startbit, mapunit);
  			goto bad;
  		}
  		if (startbit > e->highbit - mapunit) {
  			printk(KERN_ERR "security: ebitmap start bit (%d) is "
-			       "beyond the end of the bitmap (%Zd)\n",
+			       "beyond the end of the bitmap (%u)\n",
  			       startbit, (e->highbit - mapunit));
  			goto bad;
  		}
@@ -433,9 +433,8 @@ int ebitmap_read(struct ebitmap *e, void *fp)

  		index = (startbit - n->startbit) / EBITMAP_UNIT_SIZE;
  		while (map) {
-			n->maps[index] = map & (-1UL);
-			map = map >> EBITMAP_UNIT_SIZE;
-			index++;
+			n->maps[index++] = map & (-1UL);
+			map = EBITMAP_SHIFT_UNIT_SIZE(map);
  		}
  	}
  ok:
diff --git a/security/selinux/ss/ebitmap.h b/security/selinux/ss/ebitmap.h
index e38a327..f283b43 100644
--- a/security/selinux/ss/ebitmap.h
+++ b/security/selinux/ss/ebitmap.h
@@ -21,6 +21,8 @@
  #define EBITMAP_UNIT_SIZE	BITS_PER_LONG
  #define EBITMAP_SIZE		(EBITMAP_UNIT_NUMS * EBITMAP_UNIT_SIZE)
  #define EBITMAP_BIT		1ULL
+#define EBITMAP_SHIFT_UNIT_SIZE(x)					\
+	(((x) >> EBITMAP_UNIT_SIZE / 2) >> EBITMAP_UNIT_SIZE / 2)

  struct ebitmap_node {
  	struct ebitmap_node *next;

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

  reply	other threads:[~2007-10-03 13:41 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-21  4:29 [patch] Tuning avtab to reduce memory usage Yuichi Nakamura
2007-08-21 13:47 ` Stephen Smalley
2007-08-21 14:19   ` Yuichi Nakamura
2007-08-21 15:11   ` Paul Moore
2007-08-21 16:37     ` Stephen Smalley
2007-08-21 16:55       ` Paul Moore
2007-08-22  9:25         ` KaiGai Kohei
2007-09-12  3:08           ` KaiGai Kohei
2007-09-12 19:54             ` Paul Moore
2007-09-13  1:37               ` [PATCH] Improve ebitmap scanning (Re: [patch] Tuning avtab to reduce memory usage) KaiGai Kohei
2007-09-13 11:34                 ` Stephen Smalley
2007-09-14  1:02                   ` Wrappers to load bitmaps (Re: [PATCH] Improve ebitmap scanning) KaiGai Kohei
2007-09-14  1:02                     ` KaiGai Kohei
2007-09-13 20:47                 ` [PATCH] Improve ebitmap scanning (Re: [patch] Tuning avtab to reduce memory usage) Paul Moore
2007-09-18 17:21             ` [patch] Tuning avtab to reduce memory usage Stephen Smalley
2007-09-18 22:11               ` Paul Moore
2007-09-20  8:14               ` KaiGai Kohei
2007-09-21 19:21                 ` Stephen Smalley
2007-09-25  5:06                   ` KaiGai Kohei
2007-09-25 12:04                     ` Paul Moore
2007-09-25 13:53                     ` Stephen Smalley
2007-09-26  5:49                       ` [PATCH] Improve SELinux performance when AVC misses KaiGai Kohei
2007-09-27  2:22                         ` KaiGai Kohei
2007-09-27  2:43                           ` KaiGai Kohei
2007-09-27 20:47                             ` James Morris
2007-09-28 10:56                               ` KaiGai Kohei
2007-09-28 14:47                                 ` Stephen Smalley
2007-09-28 17:20                                   ` KaiGai Kohei
2007-09-28 18:40                                     ` Stephen Smalley
2007-09-28 21:09                                     ` James Morris
2007-10-02 15:12                                       ` KaiGai Kohei
2007-10-02 15:28                                         ` Stephen Smalley
2007-10-03 13:41                                           ` KaiGai Kohei [this message]
2007-10-03 14:42                                             ` KaiGai Kohei
2007-10-04  0:37                                               ` James Morris
2007-08-21 14:00 ` [patch] Tuning avtab to reduce memory usage James Morris
2007-08-22  2:55   ` Yuichi Nakamura
2007-08-22  3:42     ` KaiGai Kohei
2007-08-22 13:44     ` James Morris
2007-08-23  0:57       ` Yuichi Nakamura
2007-08-23 13:15         ` Stephen Smalley
2007-08-24  2:55           ` Yuichi Nakamura
2007-08-27 13:39             ` Stephen Smalley
2007-08-27 16:55               ` James Morris
2008-01-31 21:00             ` Stephen Smalley
2008-01-31 21:44               ` Stephen Smalley
2008-02-01  4:59               ` Yuichi Nakamura
2007-08-23 14:46         ` James Morris
2007-08-24  2:33           ` Yuichi Nakamura
2007-08-22 16:05     ` James Morris
2007-08-21 19:43 ` J. Tang
2007-08-22  3:11   ` Yuichi Nakamura

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=47039C26.1040903@kaigai.gr.jp \
    --to=kaigai@kaigai.gr.jp \
    --cc=eparis@parisplace.org \
    --cc=jmorris@namei.org \
    --cc=kaigai@ak.jp.nec.com \
    --cc=paul.moore@hp.com \
    --cc=sds@tycho.nsa.gov \
    --cc=selinux@tycho.nsa.gov \
    --cc=ynakam@hitachisoft.jp \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.