Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1695234

[PATCH v2 18/23] percpu: keep track of the best offset for contig hints

Path csiph.com!news.redatomik.org!aioe.org!bofh.it!news.nic.it!robomod
From Dennis Zhou <dennisz@fb.com>
Newsgroups linux.kernel
Subject [PATCH v2 18/23] percpu: keep track of the best offset for contig hints
Date Tue, 25 Jul 2017 01:10:01 +0200
Message-ID <u6UE9-3ig-13@gated-at.bofh.it> (permalink)
References <u6UE9-3ig-3@gated-at.bofh.it>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=O2sx/MPLChGT5Rtf4nNjOVETCEcoQEyIxGR+AuXX33Q=; b=XxKlzeMmF8hV3pcPq7b/5b/FTl4y7e/DQGu2TdXHrXQ8VtLH6S1WoGJu4LpBGm1xD8WI 2c1TfbI+sNUCmOg3c5nAOXucBh8sw6J5nB9p5Bz59ur6csgsJU16g0D36TztWYyM0B// rbiVfxQi7TToHPAq/e8nqoSJ2HfUYAE3TP0=
X-Mailer git-send-email 2.13.3
MIME-Version 1.0
Content-Type text/plain
X-Originating-IP [192.168.52.123]
X-Proofpoint-Spam-Reason safe
X-Fb-Internal Safe
X-Proofpoint-Virus-Version vendor=fsecure engine=2.50.10432:,, definitions=2017-07-24_14:,, signatures=0
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 60
Organization linux.* mail to news gateway
X-Original-Cc <linux-kernel@vger.kernel.org>, <linux-mm@kvack.org>, <kernel-team@fb.com>, Dennis Zhou <dennisszhou@gmail.com>
X-Original-Date Mon, 24 Jul 2017 19:02:15 -0400
X-Original-Message-ID <20170724230220.21774-19-dennisz@fb.com>
X-Original-References <20170724230220.21774-1-dennisz@fb.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1695234

Show key headers only | View raw


From: "Dennis Zhou (Facebook)" <dennisszhou@gmail.com>

This patch makes the contig hint starting offset optimization from the
previous patch as honest as it can be. For both chunk and block starting
offsets, make sure it keeps the starting offset with the best alignment.

The block skip optimization is added in a later patch when the
pcpu_find_block_fit iterator is swapped in.

Signed-off-by: Dennis Zhou <dennisszhou@gmail.com>
---
 mm/percpu.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/mm/percpu.c b/mm/percpu.c
index 3732373..aaad747 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -394,12 +394,18 @@ static inline int pcpu_cnt_pop_pages(struct pcpu_chunk *chunk, int bit_off,
  * @bits: size of free area
  *
  * This updates the chunk's contig hint and starting offset given a free area.
+ * Choose the best starting offset if the contig hint is equal.
  */
 static void pcpu_chunk_update(struct pcpu_chunk *chunk, int bit_off, int bits)
 {
 	if (bits > chunk->contig_bits) {
 		chunk->contig_bits_start = bit_off;
 		chunk->contig_bits = bits;
+	} else if (bits == chunk->contig_bits && chunk->contig_bits_start &&
+		   (!bit_off ||
+		    __ffs(bit_off) > __ffs(chunk->contig_bits_start))) {
+		/* use the start with the best alignment */
+		chunk->contig_bits_start = bit_off;
 	}
 }
 
@@ -454,7 +460,8 @@ static void pcpu_chunk_refresh_hint(struct pcpu_chunk *chunk)
  * @end: end offset in block
  *
  * Updates a block given a known free area.  The region [start, end) is
- * expected to be the entirety of the free area within a block.
+ * expected to be the entirety of the free area within a block.  Chooses
+ * the best starting offset if the contig hints are equal.
  */
 static void pcpu_block_update(struct pcpu_block_md *block, int start, int end)
 {
@@ -470,6 +477,10 @@ static void pcpu_block_update(struct pcpu_block_md *block, int start, int end)
 	if (contig > block->contig_hint) {
 		block->contig_hint_start = start;
 		block->contig_hint = contig;
+	} else if (block->contig_hint_start && contig == block->contig_hint &&
+		   (!start || __ffs(start) > __ffs(block->contig_hint_start))) {
+		/* use the start with the best alignment */
+		block->contig_hint_start = start;
 	}
 }
 
-- 
2.9.3

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 18/23] percpu: keep track of the best offset for contig hints Dennis Zhou <dennisz@fb.com> - 2017-07-25 01:10 +0200
  Re: [PATCH v2 18/23] percpu: keep track of the best offset for  contig hints Josef Bacik <josef@toxicpanda.com> - 2017-07-25 21:30 +0200

csiph-web