From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932863AbaHZOzz (ORCPT ); Tue, 26 Aug 2014 10:55:55 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:44785 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755459AbaHZOzx (ORCPT ); Tue, 26 Aug 2014 10:55:53 -0400 Message-ID: <53FC9FF5.7060106@fb.com> Date: Tue, 26 Aug 2014 08:55:49 -0600 From: Jens Axboe User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0 MIME-Version: 1.0 To: Alexey Dobriyan CC: Linux Kernel Subject: Re: /proc/diskstats buglet References: In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [192.168.57.29] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.12.52,1.0.27,0.0.0000 definitions=2014-08-26_05:2014-08-26,2014-08-26,1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 kscore.is_bulkscore=9.50517442532828e-13 kscore.compositescore=0 circleOfTrustscore=3224.31981307066 compositescore=0.324642340081358 urlsuspect_oldscore=0.324642340081358 suspectscore=0 recipient_domain_to_sender_totalscore=0 phishscore=0 bulkscore=0 kscore.is_spamscore=0 recipient_to_sender_totalscore=0 recipient_domain_to_sender_domain_totalscore=2524143 rbsscore=0.324642340081358 spamscore=0 recipient_to_sender_domain_totalscore=0 urlsuspectscore=0.9 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=7.0.1-1402240000 definitions=main-1408260169 X-FB-Internal: deliver Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/26/2014 08:47 AM, Alexey Dobriyan wrote: > Found and reproduced some time ago, almost forgot about :-) > > In part_round_stats_single(), ->stamp field is written but without > locking SMP-wise. > > part->stamp = now; > > So, if two processes read /proc/diskstats, it is possible for "now - > part->stamp" value to become negative. > > And indeed this can happen: > > now 4294755500, ->stamp 4294755501 > ------------[ cut here ]------------ > WARNING: CPU: 0 PID: 1950 at block/blk-core.c:1229 > part_round_stats_single+0xc0/0xd0() > ... > [] part_round_stats_single+0xc0/0xd0 > [] part_round_stats+0x47/0x70 > [] diskstats_show+0x8d/0x4b0 > ... > > Dunno how important used fields in /proc/diskstats but they can be > clearly bogus. Easiest fix is probably just to do the now - part->stamp math earlier, and ignore <= 0 instead of just now == part->stamp. I think that should be good enough for disk stats, and (most importantly), it would avoid the warning. Speaking of the warning, I don't see where that is. Where is it from? -- Jens Axboe