Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp1362794rdb; Sun, 8 Oct 2023 04:38:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF9aolsVCvBTNZ/AC40yJOEux+cNBuXpj3TYU8uy9C1cafmvfexDYi+R9Lu7r2kK+Z9Lut9 X-Received: by 2002:a05:6a20:7da0:b0:131:c760:2a0b with SMTP id v32-20020a056a207da000b00131c7602a0bmr16414092pzj.52.1696765091768; Sun, 08 Oct 2023 04:38:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696765091; cv=none; d=google.com; s=arc-20160816; b=L3qOtl/OrBlXIx7cL0n7CjNja4P7jeHZ21kLW2VBXAi1hBCJY5ZkCqPCETpIEjL2Ui 5Cqyo6wxmxkkXQKDhQFXQ+GMdTsXRFt46LbdTuebuAjxfjklYeKR4bryvoW+tmjn7XkZ plnZshe+TtmjWOdGEbHyAxEc404jLAfDSjjzlAdw+sJWCf+sL4YAAvr/XUGCGwa9BqG3 kvi7jzgb4kG53X9L/txZXMx+J7mviDTicwM92+4HfTt1Yen2WbIexuJBGRRLJjxZTtDm 0QWsQKl2ivxcKLQpoJFi4+E3CdGvC+Bni43tO1uo9hZWEavm2npWwZ2rLW4tWWW7HRvI t9Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=dd6ivPkoy5OU8m6zrjUxdg/2ojaw9JTGsy7cUreFIZk=; fh=04M1hjVXfXDpd9ZOIt5CSKP6T2LExGAZaHAJ7nnFAc0=; b=Gjr5Ym/YgnNFA6uorIJkgqHevEzPSFlKI9P0hmaRPH45npYZx34kLRW2ctzTqGzCDg 5WRnM5QQ9GfOW6cRp+85LIEVrYWlX5CR4+6Jwn/P0oRQ/fC1An+7wTvX28c8yAhmKRdz 0YuptiWK9DKrwYH1fCEMWiOg/Hy/rO652KCqjWeUlXDUWJqXfDBVwF4YdtnL1u6rJlbX dQegCmpqGBhvjjhDU2LjylPqH3DW0AlvPwFtwwORAjytBZ7QhFVvkhYeaqi5m2uJhQUe aNMUKjAVG9Xr/GUnFjQtCy4e2MoAbG3sE215iSBHem7QYScZo0eVr6vXNU4AQLYgatRB XoHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EkQE5OHk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id j26-20020a633c1a000000b005859c1e41a0si7571865pga.201.2023.10.08.04.38.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Oct 2023 04:38:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EkQE5OHk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id B45278029344; Sun, 8 Oct 2023 04:38:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344725AbjJHLiD (ORCPT + 99 others); Sun, 8 Oct 2023 07:38:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344682AbjJHLiC (ORCPT ); Sun, 8 Oct 2023 07:38:02 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D634299 for ; Sun, 8 Oct 2023 04:37:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696765035; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=dd6ivPkoy5OU8m6zrjUxdg/2ojaw9JTGsy7cUreFIZk=; b=EkQE5OHkqctA3ziJi5PKtU4KFtaJMDqJgUoZJd8iL/s8Avi5incMQOyVoJaVZxotnC02qy Wy0o/xzn1b8CjeQOu1kN1Rfpg7JLroKg4cgGok4QLsDMsiIfW390p+7NxfVl/woTf8Mk82 2e12jXvRXu5yAjTZ938JLMv023Z+AdI= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-100-_NdAhrgfP9K3XOElsbPEvw-1; Sun, 08 Oct 2023 07:37:06 -0400 X-MC-Unique: _NdAhrgfP9K3XOElsbPEvw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C0BE93804522; Sun, 8 Oct 2023 11:37:05 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.224.9]) by smtp.corp.redhat.com (Postfix) with SMTP id 625B61054FC0; Sun, 8 Oct 2023 11:37:02 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Sun, 8 Oct 2023 13:36:07 +0200 (CEST) Date: Sun, 8 Oct 2023 13:36:03 +0200 From: Oleg Nesterov To: Yu Kuai Cc: Li Nan , Khazhy Kumykov , tj@kernel.org, josef@toxicpanda.com, axboe@kernel.dk, cgroups@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, yi.zhang@huawei.com, houtao1@huawei.com, yangerkun@huawei.com, "yukuai (C)" Subject: Re: [PATCH] blk-throttle: Calculate allowed value only when the throttle is enabled Message-ID: <20231008113602.GB24726@redhat.com> References: <20230928015858.1809934-1-linan666@huaweicloud.com> <4ace01e8-6815-29d0-70ce-4632818ca701@huaweicloud.com> <20231005162417.GA32420@redhat.com> <0a8f34aa-ced9-e613-3e5f-b5e53a3ef3d9@huaweicloud.com> <20231007151607.GA24726@redhat.com> <21843836-7265-f903-a7d5-e77b07dd5a71@huaweicloud.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <21843836-7265-f903-a7d5-e77b07dd5a71@huaweicloud.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Sun, 08 Oct 2023 04:38:10 -0700 (PDT) X-Spam-Level: ** On 10/08, Yu Kuai wrote: > > >> static u64 calculate_bytes_allowed(u64 bps_limit, unsigned long > >>jiffy_elapsed) > >> { > >>+ if (jiffy_elapsed > HZ && > >>+ bps_limit > mul_u64_u64_div_u64(U64_MAX, (u64)HZ, > >>(u64)jiffy_elapsed); > >>+ return U64_MAX; > >>+ > > > >I can't suggest anything better... > > > >but I do not know if it is possible that HZ > jiffy_elapsed. If yes, then > >mul_u64_u64_div_u64() above is not safe too. > > Well, 'jiffy_elapsed > HZ' is judged before mul_u64_u64_div_u64(). Yes, sorry, somehow I didn't notice this check. Oleg.