Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp1414175imb; Sat, 2 Mar 2019 14:32:58 -0800 (PST) X-Google-Smtp-Source: AHgI3IaZ4TrY+u9zHyOwtPokD2EWHDgSvEm96ktwUVnaiYdGhr4AVkj1HSBWtJQoZH057Qq2fAr7 X-Received: by 2002:a62:b508:: with SMTP id y8mr12740782pfe.140.1551565978840; Sat, 02 Mar 2019 14:32:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551565978; cv=none; d=google.com; s=arc-20160816; b=dm5YKw8ab5K2fBKbth2oG0Y9Yu3wWToW8b4loQ2t06rYZSmby8/OnGrMEIymN1U2jY W4fL5czl4VxA50sOiIflWTAuB28Shmfrrs19LQ/5QTSQbA27qRx4zGzyamiUzdn7+3gg DyqXd191hjTmsP6RCt4XkIsm8cHJdBoEU/7HgstzisT72a/5xCRIItPB+AtIYlaBDxVk Drq9LHL/RlkHcR9n9CEFuObIdJ8NbaHWfw7OqlDYxVbg5vDCClDmU0KD90ufQCNzUWOF UDSAprbjRK8KLioyCvM7+Dmqb2ADtk91PSfY/KE37afx3xTPj5Ill9ASwUZZ/1XZcsa5 ni1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=Ynw/EvoworPJ989NZsNSzILz66FhFYqpbBC7pk+xT7U=; b=WCI+f4OgRb4xttvDxWfevAK6QD2l8BGlBkvU/ISEMyuPLDPp/1+OY8kozjypYvdVRb OdRX68pOCFbKTf4Tt8+WkiVKYNYuDYha5pJpYStJ5zh9ggeK9YJ4IzjVMYYNhMDDJxGg ectqx4vP1dshrIH6LpwY5AMRg0vr/GBB0j9NVL2ypZHQSzCrZ/w/KmAUTnlACNGYkFcw Jg5+9Jz9VDJU8n+9UOo0jVYcqzTEQORd+lACjVaDUpWTn94GltuIhZgfYwte7NshdLXn aC0TV/rO6iGZqdLcFcIzZy7o/nRJ7TBv0ASxJ2mO5L7WieSMxY9JoSvohn61/OP0EBz9 qHOQ== 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 f34si1562401ple.279.2019.03.02.14.32.43; Sat, 02 Mar 2019 14:32:58 -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 S1726681AbfCBWcQ (ORCPT + 99 others); Sat, 2 Mar 2019 17:32:16 -0500 Received: from mail-qt1-f196.google.com ([209.85.160.196]:36059 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726225AbfCBWcQ (ORCPT ); Sat, 2 Mar 2019 17:32:16 -0500 Received: by mail-qt1-f196.google.com with SMTP id p25so1447499qtb.3 for ; Sat, 02 Mar 2019 14:32:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=Ynw/EvoworPJ989NZsNSzILz66FhFYqpbBC7pk+xT7U=; b=saPq5kPxyPowJ7gZpcV63ZJpHhG2cSKyUJ2fJplpleHVAB9krpJPXKIlEW9E12kdZ5 OYUhmNHJW1xo4BI3eW7f8vc1vFofqy1oy0sUd6To63CmKz/LZdtZLFEtKWb5LGmc4v4y DhF2i8kkYN3LDpZHRl63DFdgOKwSkZL0PnFWwi2vf0kGJKUgR5ZCqYjGnn8w8DFWNa0z Us8WTiChw9I7jQ7A1Jzdf/RUPlrwWUUmqVuPLRmCLW/pFfRjUoNL7UxmaKUeNTYt1cIl zSa3VvkB6QfMMzW23qqEkGU76CEFfPj1sKmpjUZBQ+QFtUIOEWJat96eJg7kIQQav0CR DnwA== X-Gm-Message-State: APjAAAWtmGAa9+VqcG9KZt+y7su5RMNNYDUaCpvixt8UVfIRNDiXV/XN CjvXgyEp81AHP8hV2JYd3Ug= X-Received: by 2002:ac8:26a7:: with SMTP id 36mr9672393qto.234.1551565934889; Sat, 02 Mar 2019 14:32:14 -0800 (PST) Received: from dennisz-mbp.home ([2604:2000:1406:13e:1c79:146b:53ab:5b76]) by smtp.gmail.com with ESMTPSA id z9sm1118594qkj.33.2019.03.02.14.32.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 02 Mar 2019 14:32:13 -0800 (PST) Date: Sat, 2 Mar 2019 17:32:11 -0500 From: Dennis Zhou To: Peng Fan Cc: Tejun Heo , Christoph Lameter , Vlad Buslov , "kernel-team@fb.com" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 04/12] percpu: manage chunks based on contig_bits instead of free_bytes Message-ID: <20190302223211.GC1196@dennisz-mbp.home> References: <20190228021839.55779-1-dennis@kernel.org> <20190228021839.55779-5-dennis@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Mar 02, 2019 at 01:48:20PM +0000, Peng Fan wrote: > > > > -----Original Message----- > > From: owner-linux-mm@kvack.org [mailto:owner-linux-mm@kvack.org] On > > Behalf Of Dennis Zhou > > Sent: 2019年2月28日 10:19 > > 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 04/12] percpu: manage chunks based on contig_bits instead > > of free_bytes > > > > When a chunk becomes fragmented, it can end up having a large number of > > small allocation areas free. The free_bytes sorting of chunks leads to > > unnecessary checking of chunks that cannot satisfy the allocation. > > Switch to contig_bits sorting to prevent scanning chunks that may not be able > > to service the allocation request. > > > > Signed-off-by: Dennis Zhou > > --- > > mm/percpu.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/mm/percpu.c b/mm/percpu.c > > index b40112b2fc59..c996bcffbb2a 100644 > > --- a/mm/percpu.c > > +++ b/mm/percpu.c > > @@ -234,7 +234,7 @@ static int pcpu_chunk_slot(const struct pcpu_chunk > > *chunk) > > if (chunk->free_bytes < PCPU_MIN_ALLOC_SIZE || chunk->contig_bits > > == 0) > > return 0; > > > > - return pcpu_size_to_slot(chunk->free_bytes); > > + return pcpu_size_to_slot(chunk->contig_bits * PCPU_MIN_ALLOC_SIZE); > > } > > > > /* set the pointer to a chunk in a page struct */ > > Reviewed-by: Peng Fan > > Not relevant to this patch, another optimization to percpu might be good > to use per chunk spin_lock, not gobal pcpu_lock. > Percpu memory itself is expensive and for the most part shouldn't be part of the critical path. Ideally, we don't have multiple chunks being allocated simultaneously because once an allocation is given out, the chunk is pinned until all allocations are freed. Thanks, Dennis