Received: by 10.223.185.116 with SMTP id b49csp730303wrg; Sat, 10 Feb 2018 18:21:59 -0800 (PST) X-Google-Smtp-Source: AH8x2264VLweefXox1ogAYMZ/3dE2ff/mcmi2lVamq8d4oKYZJDrVuLkPz2bdx9966V6nACFNlYn X-Received: by 10.98.253.5 with SMTP id p5mr7528591pfh.132.1518315719370; Sat, 10 Feb 2018 18:21:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518315719; cv=none; d=google.com; s=arc-20160816; b=mCmEoSPpvAFGew9ckEgTXMwK/Rv20KI6gr1ixl3AQT8e16D1V6b9Pvr0qfsE+OWdpv wS5WR12FCshZt9nN18KyZldgjuXqUe3lwKIqO875xlTtPb4HUf+Ek0q3Nrb1+nLkalK2 hNXCnCxJIsKS9JFzK6ETZGqPU5diYMDl/tZTaamMVwCyNm1JR1ySezijZsdfiBaSZwux 5+Jbeh1fPQD3WE0qqV/IIo95WkYOh/mutG0IufrAV+SDK3cGFSbdQ5JhICVo/ifBBL5N eS+V5iVO6/o1dG5y3liTuggv6qJ725xRJmgV39CftTL8VZlb+Ulxqmctxjgu6q1X3H0F 86jw== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-signature :arc-authentication-results; bh=fK3Xa/Qx4Yw8FwIeh7rlmotQbzBPlqtGX+VkdurDQXA=; b=GdlXcEeZ85uuhQeNgzjECR/uE2NrBsSGU4zORz88Ew617fYVRxQBUgFbBQuwI1dT9X XpdDThA5KR9aeSnACX126i7YGU3G/EouwzbaSDWgHgz2KnDetbCNJ7t7NWoPoeWONPkO WA2Bp7ASa3soUWgFHchjbK8vKims8Ra7XL3hSLzzSQrLXylXDveWfFnItjJgSrjHGzOZ 6hz0pcH83P3u9TvsfRTlMOR4s8mw9TXS3cPo5WW/U8PY7zARMX3+nDwTZ8tZLT50ECbw 6wAZQSSpCzjW8zZL5j0j4nCX2R+jIkkiVrMGm9n3ZCNbwWrOOulS94UzkPc8jvKeJDwz 3SvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=TkqMHDq4; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=XuCT5ION; 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 o3-v6si3794873plk.533.2018.02.10.18.21.33; Sat, 10 Feb 2018 18:21:59 -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; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=TkqMHDq4; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=XuCT5ION; 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 S1751806AbeBKCUd (ORCPT + 99 others); Sat, 10 Feb 2018 21:20:33 -0500 Received: from casper.infradead.org ([85.118.1.10]:49702 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751050AbeBKCUb (ORCPT ); Sat, 10 Feb 2018 21:20:31 -0500 X-Greylist: delayed 2633 seconds by postgrey-1.27 at vger.kernel.org; Sat, 10 Feb 2018 21:20:31 EST DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=fK3Xa/Qx4Yw8FwIeh7rlmotQbzBPlqtGX+VkdurDQXA=; b=TkqMHDq4bVJe+9yAor+LULHEf YWMUmvZ6BMht6UtzeYeWrwM0ZIE6W3vi+OuvAfY4kAXzUP/PvCuc15pMoKn+NUBj2uQ/l/tGQ9t44 CZDQaagc0dsY4Yxe1MrxMgRhXEKBuP9mFhK0/GVloO2PKhaWKhitivWshdde1ykgDxnj/kczOKyLI D+rWHeN8ONjWiu+2/ZjG0FgMIb40HJ2v/RKm4a6kuuGGABc3MudP0m1gjvInwlJLxbYCo/oRuIo4r yvgGjDpUlckYDHZzT8bFPtRI8qqo6jSW/y7gCgQc3yZD5CICxlX0fh4qc75G1UioV7lF9jVXSuq1c T8BQ0assA==; Received: from [198.137.202.133] (helo=bombadil.infradead.org) by casper.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ekgZI-00019x-Ey; Sun, 11 Feb 2018 01:36:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=fK3Xa/Qx4Yw8FwIeh7rlmotQbzBPlqtGX+VkdurDQXA=; b=XuCT5IONP1roI4I3tcfCEKbU2 Bx2WpKAiJ8i9T/ItjVKKYT92SFgvCjLlcbd9OcYzuSS90lRrq/0Gqa2TeHlAURx3dZT7YfS5Mxtn7 shdTDZVkcAL5nAMdmgNw+kKDLPPT/BvIfQewdUh2lnYDoAGv5ZQH0sALDuS0RC6sn5SRgDxs9ODEp sLrQPahF/i+kpaAis7usYxf+iiF3MPv/Zqx4/nri7k+7oA3iBfn5+T5TvWyDJZCaPI5DjqqGy0dcV LzuReQhKEq7QwI/y/oWopZ81JsnaJ2KjpVGq4Km5SPNlSv2Cm5H8DGBt+aSydKi0wuMyqH1GRXA95 KC9ybYHBg==; Received: from willy by bombadil.infradead.org with local (Exim 4.89 #1 (Red Hat Linux)) id 1ekg1q-0005M4-0c; Sun, 11 Feb 2018 01:02:02 +0000 Date: Sat, 10 Feb 2018 17:02:01 -0800 From: Matthew Wilcox To: Joe Perches Cc: Donglin Peng , viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, Linux Kernel Mailing List Subject: Re: [PATCH] seq_file: remove redundant assignment of index to m->index Message-ID: <20180211010201.GA14719@bombadil.infradead.org> References: <1518285863.16865.17.camel@perches.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1518285863.16865.17.camel@perches.com> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Feb 10, 2018 at 10:04:23AM -0800, Joe Perches wrote: > > @@ -120,14 +120,12 @@ static int traverse(struct seq_file *m, loff_t offset) > > if (pos + m->count > offset) { > > m->from = offset - pos; > > m->count -= m->from; > > - m->index = index; > > break; > > } > > pos += m->count; > > m->count = 0; > > if (pos == offset) { > > index++; > > - m->index = index; > > break; > > } > > p = m->op->next(m, p, &index); > > Of course this looks correct, but how > are you _absolutely sure_ about this? > > Perhaps the m->op->stop(m, p) call below > the break, which takes m as an argument, > needs an updated m->index. Not only that, but ->next might also look at m->index. This is not performance critical; don't try to optimise it. Programmers waste enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered. We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%. -- Donald Knuth