From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755266AbYJOBhf (ORCPT ); Tue, 14 Oct 2008 21:37:35 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752056AbYJOBhY (ORCPT ); Tue, 14 Oct 2008 21:37:24 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:63999 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751276AbYJOBhW (ORCPT ); Tue, 14 Oct 2008 21:37:22 -0400 Message-ID: <48F548C7.6010609@cn.fujitsu.com> Date: Wed, 15 Oct 2008 09:35:03 +0800 From: Lai Jiangshan User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) MIME-Version: 1.0 To: Alexey Dobriyan CC: Andrew Morton , Paul Menage , Paul Jackson , Linux Kernel Mailing List Subject: Re: [PATCH 1/4] seq_file: don't call bitmap_scnprintf_len() References: <48F1C36D.6080301@cn.fujitsu.com> <20081013063806.GB3596@x200.localdomain> <48F2F620.9020305@cn.fujitsu.com> In-Reply-To: <48F2F620.9020305@cn.fujitsu.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Lai Jiangshan wrote: > Alexey Dobriyan wrote: >> On Sun, Oct 12, 2008 at 05:29:17PM +0800, Lai Jiangshan wrote: >>> "m->count + len < m->size" is true commonly, so bitmap_scnprintf() >>> is commonly called. this fix saves a call to bitmap_scnprintf_len(). >> This saves a call if seq buffer is already full which is not a common >> situation, so you're optimising for rare situations and adding branch >> for common ones. > > Hi Alexey > > I think this saves a call if seq buffer is _not_ full after called. > > since calling bitmap_scnprintf() is the common situation. so we use > the return value of bitmap_scnprintf() instead of bitmap_scnprintf_len(). > > In old code bitmap_scnprintf_len() and bitmap_scnprintf() must be called > commonly. > > Thanks Lai. Hi, Alexey, Have noticed this comment? I hold my ground, ;-) And seq_cpumask_list(), seq_nodemask_list() are needed for print mask safely, Should I send independent patches for them if we can't make an agreement about this fix. Lai > >>> --- a/fs/seq_file.c >>> +++ b/fs/seq_file.c >>> @@ -452,17 +452,18 @@ int seq_dentry(struct seq_file *m, struct dentry *dentry, char *esc) >>> >>> int seq_bitmap(struct seq_file *m, unsigned long *bits, unsigned int nr_bits) >>> { >>> - size_t len = bitmap_scnprintf_len(nr_bits); >>> - >>> - if (m->count + len < m->size) { >>> - bitmap_scnprintf(m->buf + m->count, m->size - m->count, >>> - bits, nr_bits); >>> - m->count += len; >>> - return 0; >>> + if (m->count < m->size) { >>> + int len = bitmap_scnprintf(m->buf + m->count, >>> + m->size - m->count, bits, nr_bits); >>> + if (m->count + len < m->size) { >>> + m->count += len; >>> + return 0; >>> + } >>> } >>> m->count = m->size; >>> return -1; >>> } >>> +EXPORT_SYMBOL(seq_bitmap); >> Modular users, where are they? >> >> >> > >