From: ebiederm@xmission.com (Eric W. Biederman)
To: Christian Brauner <christian.brauner@ubuntu.com>
Cc: linux-kernel@vger.kernel.org, serge@hallyn.com, tycho@tycho.ws,
Linux Containers <containers@lists.linux-foundation.org>
Subject: [PATCH 4/5] userns: Make map_id_down a wrapper for map_id_range_down
Date: Tue, 31 Oct 2017 18:48:46 -0500 [thread overview]
Message-ID: <87efpiswtd.fsf_-_@xmission.com> (raw)
In-Reply-To: <871sliubhj.fsf_-_@xmission.com> (Eric W. Biederman's message of "Tue, 31 Oct 2017 18:46:32 -0500")
There is no good reason for this code duplication, the number of cache
line accesses not the number of instructions are the bottleneck in
this code.
Therefore simplify maintenance by removing unnecessary code.
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
kernel/user_namespace.c | 38 +-------------------------------------
1 file changed, 1 insertion(+), 37 deletions(-)
diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
index 4f7e357ac1e2..1d0298870ee3 100644
--- a/kernel/user_namespace.c
+++ b/kernel/user_namespace.c
@@ -313,45 +313,9 @@ static u32 map_id_range_down(struct uid_gid_map *map, u32 id, u32 count)
return id;
}
-/**
- * map_id_down_base - Find idmap via binary search in static extent array.
- * Can only be called if number of mappings is equal or less than
- * UID_GID_MAP_MAX_BASE_EXTENTS.
- */
-static struct uid_gid_extent *
-map_id_down_base(unsigned extents, struct uid_gid_map *map, u32 id)
-{
- unsigned idx;
- u32 first, last;
-
- /* Find the matching extent */
- for (idx = 0; idx < extents; idx++) {
- first = map->extent[idx].first;
- last = first + map->extent[idx].count - 1;
- if (id >= first && id <= last)
- return &map->extent[idx];
- }
- return NULL;
-}
-
static u32 map_id_down(struct uid_gid_map *map, u32 id)
{
- struct uid_gid_extent *extent;
- unsigned extents = map->nr_extents;
- smp_rmb();
-
- if (extents <= UID_GID_MAP_MAX_BASE_EXTENTS)
- extent = map_id_down_base(extents, map, id);
- else
- extent = map_id_range_down_max(extents, map, id, 1);
-
- /* Map the id or note failure */
- if (extent)
- id = (id - extent->first) + extent->lower_first;
- else
- id = (u32) -1;
-
- return id;
+ return map_id_range_down(map, id, 1);
}
/**
--
2.14.1
next prev parent reply other threads:[~2017-10-31 23:48 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-24 22:04 [PATCH 1/2 v6] user namespace: use union in {g,u}idmap struct Christian Brauner
2017-10-24 22:04 ` [PATCH 2/2 v6] user namespaces: bump idmap limits to 340 Christian Brauner
2017-10-31 23:46 ` [PATCH 0/5] userns: bump idmap limits, fixes & tweaks Eric W. Biederman
2017-10-31 23:47 ` [PATCH 1/5] userns: Don't special case a count of 0 Eric W. Biederman
2017-10-31 23:47 ` [PATCH 2/5] userns: Simplify the user and group mapping functions Eric W. Biederman
2017-10-31 23:48 ` [PATCH 3/5] userns: Don't read extents twice in m_start Eric W. Biederman
2017-11-01 8:31 ` Nikolay Borisov
2017-11-01 11:08 ` Eric W. Biederman
2017-11-01 13:05 ` Nikolay Borisov
2017-11-01 13:05 ` Peter Zijlstra
2017-11-01 14:01 ` Christian Brauner
2017-11-01 14:16 ` Peter Zijlstra
2017-11-01 16:29 ` Christian Brauner
2017-11-01 16:31 ` Christian Brauner
2017-11-01 17:00 ` Joe Perches
2017-11-01 17:20 ` Eric W. Biederman
2017-11-01 18:15 ` Peter Zijlstra
2017-10-31 23:48 ` Eric W. Biederman [this message]
2017-10-31 23:49 ` [PATCH 5/5] userns: Simplify insert_extent Eric W. Biederman
2017-11-01 10:51 ` [PATCH 0/5] userns: bump idmap limits, fixes & tweaks Christian Brauner
2017-11-01 11:15 ` Eric W. Biederman
2017-11-01 13:31 ` Christian Brauner
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=87efpiswtd.fsf_-_@xmission.com \
--to=ebiederm@xmission.com \
--cc=christian.brauner@ubuntu.com \
--cc=containers@lists.linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=serge@hallyn.com \
--cc=tycho@tycho.ws \
/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