linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: linux-fsdevel@vger.kernel.org
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	linux-kernel@vger.kernel.org, Stephen Tweedie <sct@redhat.com>,
	Jeremy Eder <jeder@redhat.com>
Subject: [PATCH 2/5][RFC][CFT] fold pcpu_split_block() into the only caller
Date: Wed, 5 Mar 2014 03:50:10 +0000	[thread overview]
Message-ID: <20140305035009.GB26528@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20140305034751.GW18016@ZenIV.linux.org.uk>

... and clean it up a bit

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 mm/percpu.c |   58 ++++++++++++----------------------------------------------
 1 file changed, 12 insertions(+), 46 deletions(-)

diff --git a/mm/percpu.c b/mm/percpu.c
index 4469fbd..383801e 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -419,47 +419,6 @@ out_unlock:
 }
 
 /**
- * pcpu_split_block - split a map block
- * @chunk: chunk of interest
- * @i: index of map block to split
- * @head: head size in bytes (can be 0)
- * @tail: tail size in bytes (can be 0)
- *
- * Split the @i'th map block into two or three blocks.  If @head is
- * non-zero, @head bytes block is inserted before block @i moving it
- * to @i+1 and reducing its size by @head bytes.
- *
- * If @tail is non-zero, the target block, which can be @i or @i+1
- * depending on @head, is reduced by @tail bytes and @tail byte block
- * is inserted after the target block.
- *
- * @chunk->map must have enough free slots to accommodate the split.
- *
- * CONTEXT:
- * pcpu_lock.
- */
-static void pcpu_split_block(struct pcpu_chunk *chunk, int i,
-			     int head, int size, int tail)
-{
-	int nr_extra = !!head + !!tail;
-	int off;
-
-	BUG_ON(chunk->map_alloc <= chunk->map_used + nr_extra);
-
-	/* insert new subblocks */
-	memmove(&chunk->map[i + nr_extra] + 1, &chunk->map[i] + 1,
-		sizeof(chunk->map[0]) * (chunk->map_used - i));
-	chunk->map_used += nr_extra;
-
-	off = chunk->map[i];
-
-	if (head)
-		chunk->map[++i] = off += head;
-	if (tail)
-		chunk->map[++i] = off += size;
-}
-
-/**
  * pcpu_alloc_area - allocate area from a pcpu_chunk
  * @chunk: chunk of interest
  * @size: wanted size in bytes
@@ -530,19 +489,26 @@ static int pcpu_alloc_area(struct pcpu_chunk *chunk, int size, int align)
 
 		/* split if warranted */
 		if (head || tail) {
-			pcpu_split_block(chunk, i, head, size, tail);
+			int nr_extra = !!head + !!tail;
+
+			/* insert new subblocks */
+			memmove(p + nr_extra + 1, p + 1,
+				sizeof(chunk->map[0]) * (chunk->map_used - i));
+			chunk->map_used += nr_extra;
+
 			if (head) {
 				if (!seen_free) {
 					chunk->first_free = i;
 					seen_free = 1;
 				}
-				i++;
-				p++;
-				off += head;
+				*++p = off += head;
+				++i;
 				max_contig = max(head, max_contig);
 			}
-			if (tail)
+			if (tail) {
+				p[1] = off + size;
 				max_contig = max(tail, max_contig);
+			}
 		}
 
 		if (!seen_free)
-- 
1.7.10.4


  parent reply	other threads:[~2014-03-05  3:50 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-05  3:47 [PATCHES][RFC][CFT] scalability fixes for shitloads of mounts Al Viro
2014-03-05  3:49 ` [PATCH 1/5][RFC][CFT] percpu fixes, part 1 Al Viro
2014-03-06 19:20   ` Tejun Heo
2014-03-06 20:30     ` Al Viro
2014-03-06 20:47       ` Tejun Heo
2014-03-07  2:52         ` Al Viro
2014-03-07 12:30           ` Tejun Heo
2014-03-14 18:45           ` Al Viro
2014-03-14 18:47             ` Tejun Heo
2014-03-14 18:53               ` Al Viro
2014-03-17 20:12                 ` [PATCH percpu/for-3.15] percpu: allocation size should be even Tejun Heo
2014-03-05  3:50 ` Al Viro [this message]
2014-03-06 19:21   ` [PATCH 2/5][RFC][CFT] fold pcpu_split_block() into the only caller Tejun Heo
2014-03-05  3:51 ` [PATCH 3/5][RFC][CFT] smarter propagate_mnt() Al Viro
2014-03-05  3:51 ` [PATCH 4/5][RFC][CFT] reduce m_start() cost Al Viro
2014-03-05  3:52 ` [PATCH 5/5][RFC][CFT] resizable namespace.c hashes Al Viro
2014-03-07 17:17   ` Andi Kleen
2014-03-07 18:38     ` Al Viro

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=20140305035009.GB26528@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=jeder@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sct@redhat.com \
    --cc=torvalds@linux-foundation.org \
    /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;
as well as URLs for NNTP newsgroup(s).