From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751898AbcGRS3z (ORCPT ); Mon, 18 Jul 2016 14:29:55 -0400 Received: from mail-io0-f195.google.com ([209.85.223.195]:34525 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751463AbcGRS3x (ORCPT ); Mon, 18 Jul 2016 14:29:53 -0400 MIME-Version: 1.0 In-Reply-To: <146867813621.23552.6234170020058724059.stgit@buzz> References: <146867813621.23552.6234170020058724059.stgit@buzz> From: Cong Wang Date: Mon, 18 Jul 2016 11:29:33 -0700 Message-ID: Subject: Re: [PATCH] net/sched/sch_htb: clamp xstats tokens to fit into 32-bit int To: Konstantin Khlebnikov Cc: "David S. Miller" , Linux Kernel Network Developers , Eric Dumazet , Jamal Hadi Salim , LKML Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jul 16, 2016 at 7:08 AM, Konstantin Khlebnikov wrote: > In kernel HTB keeps tokens in signed 64-bit in nanoseconds. In netlink > protocol these values are converted into pshed ticks (64ns for now) and > truncated to 32-bit. In struct tc_htb_xstats fields "tokens" and "ctokens" > are declared as unsigned 32-bit but they could be negative thus tool 'tc' > prints them as signed. Big values loose higher bits and/or become negative. > > This patch clamps tokens in xstat into range from INT_MIN to INT_MAX. > In this way it's easier to understand what's going on here. Makes sense to me, I don't know why we didn't use signed int in the beginning, interpreting an unsigned int as signed is confusing.