Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp126489img; Wed, 27 Feb 2019 18:20:12 -0800 (PST) X-Google-Smtp-Source: AHgI3IY7WISW037b8i52mrmiI4TD1KIrEuLfnswoAFfResLGXcMquiBa8pT79wUdUM0Ku5iNNgFZ X-Received: by 2002:a65:4203:: with SMTP id c3mr6109385pgq.271.1551320412828; Wed, 27 Feb 2019 18:20:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551320412; cv=none; d=google.com; s=arc-20160816; b=MUYn1nq5/1p6UkQV99A2mq477viC3utZQNLIiD/kYyhZdZtdC2ciAhp3BCi0Do3M57 5WQ2lODLRPCgg1iGLhx4A9Pg3Jeg/0RIaZ6sopigu5f9z1bRT4K8hctWak8Yp1P9P+dL 31ymc7u3fKoJ4wuV/mWlC0yjmVjmg3Fs6k3Zg+iBTTbEE8gYZ+3Aa3xxBpLZix/xOMtg XvWMZM401otQi4/4N/Fmjgze1ayz3hXHtyDNqmPPDgbqaa7/MQlPK6gs5wB1ZMvSUvmR Fb9HNFqhrkxidQcResRw4RiY/vcLFsgGIeIS4UMKbLi8UPWXJ2+jMGyZOjczNCOfIefc W/Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=sHVgXKJ/dpov8r/5Fytj2IJVQNeHCHiREVwJuyicgyI=; b=EuakuBj/keohYAnfYwmrsTTK5B+LF+CAQdNlY/k2gmU9deOOP75qaqUT9798cX08rS 337KA4i6DYA94OPta8rB7hwYgozWV+BqwLMEEzCPLYoBKLs/+xlxiN+2pY78cla4XX0y EQ3JO0KmuEqIzyt1WcOd7pKCgUvws/Ok8gEaGSBImraHl5uB/63AP0I+yUOSoYjAfIOa uh2Jd2iNqqv7Dwcsats4TxHrmJoE+xrrXH3DHsjiklfTNjQyUhoiTcmyDBDPpVh99sHO 7wmCoY9ybPzX0ckNQ47sArPWIp/MFOh2XwnS1BMmyj5crTlizU839L96gh9pgAjpjQ0g 3SRA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t18si14468219pgv.285.2019.02.27.18.19.57; Wed, 27 Feb 2019 18:20:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730844AbfB1CTS (ORCPT + 99 others); Wed, 27 Feb 2019 21:19:18 -0500 Received: from mail-qk1-f194.google.com ([209.85.222.194]:37188 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730706AbfB1CS6 (ORCPT ); Wed, 27 Feb 2019 21:18:58 -0500 Received: by mail-qk1-f194.google.com with SMTP id m9so11207401qkl.4 for ; Wed, 27 Feb 2019 18:18:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=sHVgXKJ/dpov8r/5Fytj2IJVQNeHCHiREVwJuyicgyI=; b=SmKt7tHsUkt0UPGK5fE3FiZFN1lZcLWfNaKMZquZrUxch+F32rPPtPacbgQkvMDh2G KR5yLG5CQWwN19RoRGZ4SljaFJbsBIKUHaY8hotTMbQwfflHwdvxNImyyaifwHMzxm/s O0/oZxvEPNb1/kdYm2GG5b0iLrZv/SxWjKoZsyw8HdNcnkd9flzydZ3cb3V07rAak1GM 9wvfHTa6MT+tJ4BYjRSE0Eth7Q/eW7nW4xajKLB8SGIpZ8Zys2EXP3syBeqjUqTv6g5T wTt9NRabjZYp5hZcIhT0xRC7YdR0RISxHPs21ja7yE+PTS9qFwgskPNMwuYZOqvhsI6S Z4Jg== X-Gm-Message-State: AHQUAuYwhuLDpCe/kqsK+Vi/4TYtLde1Ig78ZHCTdAm1BfS5vfKVnULR lVs+ajRGcfi+p/TwOJ4WNts= X-Received: by 2002:a37:4d52:: with SMTP id a79mr4678440qkb.75.1551320337168; Wed, 27 Feb 2019 18:18:57 -0800 (PST) Received: from localhost.localdomain (cpe-98-13-254-243.nyc.res.rr.com. [98.13.254.243]) by smtp.gmail.com with ESMTPSA id y21sm12048357qth.90.2019.02.27.18.18.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 27 Feb 2019 18:18:56 -0800 (PST) From: Dennis Zhou To: Dennis Zhou , Tejun Heo , Christoph Lameter Cc: Vlad Buslov , kernel-team@fb.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/12] percpu: use block scan_hint to only scan forward Date: Wed, 27 Feb 2019 21:18:36 -0500 Message-Id: <20190228021839.55779-10-dennis@kernel.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20190228021839.55779-1-dennis@kernel.org> References: <20190228021839.55779-1-dennis@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Blocks now remember the latest scan_hint. This can be used on the allocation path as when a contig_hint is broken, we can promote the scan_hint to the contig_hint and scan forward from there. This works because pcpu_block_refresh_hint() is only called on the allocation path while block free regions are updated manually in pcpu_block_update_hint_free(). Signed-off-by: Dennis Zhou --- mm/percpu.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/mm/percpu.c b/mm/percpu.c index dac18968d79f..e51c151ed692 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -765,14 +765,23 @@ static void pcpu_block_refresh_hint(struct pcpu_chunk *chunk, int index) { struct pcpu_block_md *block = chunk->md_blocks + index; unsigned long *alloc_map = pcpu_index_alloc_map(chunk, index); - int rs, re; /* region start, region end */ + int rs, re, start; /* region start, region end */ + + /* promote scan_hint to contig_hint */ + if (block->scan_hint) { + start = block->scan_hint_start + block->scan_hint; + block->contig_hint_start = block->scan_hint_start; + block->contig_hint = block->scan_hint; + block->scan_hint = 0; + } else { + start = block->first_free; + block->contig_hint = 0; + } - /* clear hints */ - block->contig_hint = block->scan_hint = 0; - block->left_free = block->right_free = 0; + block->right_free = 0; /* iterate over free areas and update the contig hints */ - pcpu_for_each_unpop_region(alloc_map, rs, re, block->first_free, + pcpu_for_each_unpop_region(alloc_map, rs, re, start, PCPU_BITMAP_BLOCK_BITS) { pcpu_block_update(block, rs, re); } @@ -837,6 +846,8 @@ static void pcpu_block_update_hint_alloc(struct pcpu_chunk *chunk, int bit_off, s_off, s_off + bits)) { /* block contig hint is broken - scan to fix it */ + if (!s_off) + s_block->left_free = 0; pcpu_block_refresh_hint(chunk, s_index); } else { /* update left and right contig manually */ @@ -870,11 +881,11 @@ static void pcpu_block_update_hint_alloc(struct pcpu_chunk *chunk, int bit_off, if (e_off > e_block->scan_hint_start) e_block->scan_hint = 0; + e_block->left_free = 0; if (e_off > e_block->contig_hint_start) { /* contig hint is broken - scan to fix it */ pcpu_block_refresh_hint(chunk, e_index); } else { - e_block->left_free = 0; e_block->right_free = min_t(int, e_block->right_free, PCPU_BITMAP_BLOCK_BITS - e_off); -- 2.17.1