Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp5521317imb; Thu, 7 Mar 2019 18:20:01 -0800 (PST) X-Google-Smtp-Source: APXvYqyluh2N80x/+OkyI7j3HMx7y3HUmvuZAMX/21GzzB4gggPpN2hCxOyaqOE7c4FiuiiinUbs X-Received: by 2002:a63:2882:: with SMTP id o124mr14502015pgo.446.1552011601170; Thu, 07 Mar 2019 18:20:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552011601; cv=none; d=google.com; s=arc-20160816; b=tMaS7eDol3iaSFTd7VHa/vO3NVUOMSPu7pw1Yc/MlJp6g3sioM4XeTbTqYj67pM8ob doEafALKepVwcHGmVXFPtWf7fMlAlOs4Z0FsHLR0yTeeUxtlVpwWIcNTNSqq5YdzBab7 zn1/EmMoJ9PidaV/XnRWxaQZAmYlbx+rcM3n3GDSDUStLyHG0Csmktguj1T/8GQmCye8 uoaBZjilQ/iTlnibuz0xXkwRovWT21xk4yy7Wpdu905I5+Vz0LxbFtru3wp6OBr8oVNe T8A6q9dwEPk14m+o4O42WSKz0/kbj17xHdA6frpwzePOXe+AXQgCYh7SmKBbEbIHusd5 IDsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:openpgp:from:references:cc:to:subject; bh=8m0H8SB5VjmTm0/MSfRPgRwZ77Wuji6UrsLVB2JLyk0=; b=YtOS1bEHZbrrmnD1H7waG2wMNlvUV8E5vtITvYo+hSOsys/f4W3bkf4IvBNz5i9r9D X4o/J2YwiIc7wzookRqBazQxcXjiUzHJxgXjDiLWEls9xnZ2uWwMMiB3WbxguNWaxtWl a/FooyxJhBlIPRAjn1H2Zw48sNKiLETXVmOs0Rbv1LBNVQ8gIJPCUmqLumuFSBTrbLcm c/rDUg81nlo+KxooWpP0BDL9GPxhR/FUCTOQ2OLYPZAqGMwna1K2Eei0XIL7B+R8cO/H MrKBoSEkOMg3Ms9pfSfGQWjswyVfZCalRFD5JNyhk2EL0DxqcTQqpP2rEzox6kjS6edO 38hA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s6si5647624plq.160.2019.03.07.18.19.43; Thu, 07 Mar 2019 18:20:01 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726283AbfCHCTX (ORCPT + 99 others); Thu, 7 Mar 2019 21:19:23 -0500 Received: from mx2.suse.de ([195.135.220.15]:58420 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726242AbfCHCTW (ORCPT ); Thu, 7 Mar 2019 21:19:22 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id AC0F9AF2F; Fri, 8 Mar 2019 02:19:21 +0000 (UTC) Subject: Re: [PATCH] bcache: add cond_resched() in __bch_cache_cmp() To: Shile Zhang Cc: Vojtech Pavlik , Kent Overstreet , linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org References: <1551935728-243664-1-git-send-email-shile.zhang@linux.alibaba.com> <24916a71-39ff-7324-ad12-9d79cc68d0da@suse.de> <3640cd7f-f32a-1509-dbef-6000b6e14e75@linux.alibaba.com> <20190307154421.GA8829@suse.cz> From: Coly Li Openpgp: preference=signencrypt Organization: SUSE Labs Message-ID: Date: Fri, 8 Mar 2019 10:19:15 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.5.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019/3/8 8:35 上午, Shile Zhang wrote: > > On 2019/3/7 23:44, Vojtech Pavlik wrote: >> On Thu, Mar 07, 2019 at 11:36:18PM +0800, Coly Li wrote: >>> On 2019/3/7 11:06 下午, Shile Zhang wrote: >>>> On 2019/3/7 18:34, Coly Li wrote: >>>>> On 2019/3/7 1:15 下午, shile.zhang@linux.alibaba.com wrote: >>>>>> From: Shile Zhang >>>>>> >>>>>> Read /sys/fs/bcache//cacheN/priority_stats can take very long >>>>>> time with huge cache after long run. >>>>>> >>>>>> Signed-off-by: Shile Zhang >>>>> Hi Shile, >>>>> >>>>> Do you test your change ? It will be helpful with more performance >>>>> data >>>>> (what problem that you improved). >>>> In case of 960GB SSD cache device, once read of the 'priority_stats' >>>> costs about 600ms in our test environment. >>>> >>> After the fix, how much time it takes ? >>> >>> >>>> The perf tool shown that near 50% CPU time consumed by 'sort()', this >>>> means once sort will hold the CPU near 300ms. >>>> >>>> In our case, the statistics collector reads the 'priority_stats' >>>> periodically, it will trigger the schedule latency jitters of the >>>> >>>> task which shared same CPU core. >>>> >>> Hmm, it seems you just make the sort slower, and nothing more changes. >>> Am I right ? >> Well, it has to make the sort slower, but it'll also avoid hogging the >> CPU (on a non-preemptible kernel), avoiding a potential soft lockup >> warning and allowing other tasks to run. >> > Yes, there is a risk that other tasks have no chance to run due to sort > hogging the CPU, it is harmful to some schedule-latency sensitive tasks. > This change just try to reduce the impact of sort, but not a performance > improvement of it. I'm not sure if a better way can handle it more > efficiency. I know the above concept, since I would expect when people talking about performance improvement, it would be better to provide real performance number. Under some conditions it might be hard, but in this exact example, it won't. Could you please provide some data that on your configuration, how slow 'sort' becomes ? AND, reading priority_stats in period for performance monitoring is not good idea. The problem is not from 'sort', it is from mutex_lock(&ca->set->bucket_lock) lines above the sort in sysfs.c, when you have a quite large or very busy cache device, you may see normal I/O performance drops due to too much time holding bucket_lock here. Anyway, this is just my suggestion. Back to this patch, please provide performance number. Thanks. Coly Li