Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp321645pxy; Fri, 30 Apr 2021 06:16:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdeR8tYlNYSi1s2y5sfxgPGkDQgtr0KKWVWOBS9T8hkbgFBxsgNqOXJgZ6N7QehOIKSVvS X-Received: by 2002:a50:9e4f:: with SMTP id z73mr5786140ede.338.1619788598326; Fri, 30 Apr 2021 06:16:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619788598; cv=none; d=google.com; s=arc-20160816; b=C3yD3s/Ys8P4G5z1SYWlaKbUfG2Onlgj9Mf6tiQFqVKzMp34aE4imYt8ifP+V8tdqt 0FXhx0BoRPfmvkPydofGfXZQFIE7oevWbQNr3d9tyLGZkihayiNZV8lM/Eth4Tcm2KSX 0Gp3M8qkfSfKSD+GxBSamTuqZ4Zo6Nr++Oy4M8rhrQYTKQDnhcHcbEtf4w2pEnShoqSf CzWFgSdZcTeV8KG2kJ/ml4/UJAQ+sQ8YLWpvvGqEssZH9AG93LLi6+jNAre0oY9O59Le DWTxI/tjHfcxTfOGm4DE6+3lnZbWZoknbWe1fmOcLIceVQP0YfQVvbLFGBHEsGP1fDN5 56FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=MPQPUN5VCn1ijxvAhjY2Rhy4FDLKQuGmZG+s6D8CjGk=; b=GeSI0a6jHUPi/M2JORykNF/cLhC5tCG4CpM/ekv9ZJIk8t40+LhLGOaJ1snBfTop85 9EyMwDQapiTkBZ1l0jZ+9S3189nr2jIHpQ1nKuLQ74SLFcSIsWMvF1xfhD9YeIqGQ13d EKf3mX7S59hP4P9SESplZ6kPvG2I1iFfD3Id/1jKXOx5s0ko+cboE3+ZMCUjtTorAVGs 2FCwsg7IpuAI/EcYPsJ/WogA3stXpLWl+68+nLvsIb7lXgtzlwrxFgfV5TkVpwgoiBrG 4vhmmKKek/acAG7lZdtrehTIdEJQoh8WUuChDKM44wen+uy42Er+GSuvJ8Og9ydaz4YC /IKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=s+LK+3u2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn13si1894691edb.270.2021.04.30.06.16.14; Fri, 30 Apr 2021 06:16:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=s+LK+3u2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232224AbhD3NPd (ORCPT + 99 others); Fri, 30 Apr 2021 09:15:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230020AbhD3NPc (ORCPT ); Fri, 30 Apr 2021 09:15:32 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0F74C06174A for ; Fri, 30 Apr 2021 06:14:42 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id z6so9258194wrm.4 for ; Fri, 30 Apr 2021 06:14:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=MPQPUN5VCn1ijxvAhjY2Rhy4FDLKQuGmZG+s6D8CjGk=; b=s+LK+3u2rwaMR0Hq51Bgtf8cGpb+ZSw5N68z8L+M07fjdgHyS/nCLLjVhnkkQo01d9 XxkMXuPShO+2EABhOCOShlVK3i32UaQRZTGQkgZL6kwtuxuhAlRoXVeAU9kkr4WnksXY /Tx+xxQ3wIFoicgev/NBgykX675iLwqf86O0hz/RkeurIS0YdwJ55Ol0Uqrm/xAfKzKy 4ExiTjnFS5AZTzdAYZo+v4fR1Tn9dwbmfcl+aq5QG5Iy6BhN82B9qEty6P+gAEBfqkeb t29Ho6iWN7HyaYDsnyFWIWpvy+Vnm7z7EkBxWW6ZChnaEe5BBdp7fqiGZ+hZXcfdTQXw Zu5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=MPQPUN5VCn1ijxvAhjY2Rhy4FDLKQuGmZG+s6D8CjGk=; b=Uaris+K8eKe3oJz9gh7p33UmUo2pdJz5f6n3WYb2zMm/gI6mKStAvSWA0JWEI3smKq 5xPuRWsapTmQ268N1Rai3Ws0cgQBXQfSEwwSLqpN6YF5WZIviKE2Hr84L5Zqw/mI20K0 ykXO+QpS0eWN5czobypxmPtZHArZLcst4HfbAJmVkfMsCKjakp3drrcSNGKzBXj4g7i6 5ekhVe76U3tzWk9lhYBRdt55Ngd+RwA/uXGOX5OuS4+55hZJ2CnlBPqECt17psyDUlTL Vy1SxRUrMEPwqR2EZZVz3CIS8tCr45ZELyxAcD0yJ7c/RtH76BTj+IICr6EvrYqxkeD4 yJag== X-Gm-Message-State: AOAM530yimETdxD1mFJ8GxFGIjgXnsgIOl3CpYJDtHM7VMFrTNwTtPOj I2K7MMecCTRsQOpfpZBPIUANDg== X-Received: by 2002:a5d:54c9:: with SMTP id x9mr6694932wrv.91.1619788481511; Fri, 30 Apr 2021 06:14:41 -0700 (PDT) Received: from google.com (105.168.195.35.bc.googleusercontent.com. [35.195.168.105]) by smtp.gmail.com with ESMTPSA id d6sm2220401wrr.77.2021.04.30.06.14.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Apr 2021 06:14:40 -0700 (PDT) Date: Fri, 30 Apr 2021 13:14:38 +0000 From: Quentin Perret To: Dietmar Eggemann Cc: Vincent Guittot , Ingo Molnar , Peter Zijlstra , Juri Lelli , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Qais Yousef , Android Kernel Team , linux-kernel , Patrick Bellasi Subject: Re: [PATCH v2] sched: Fix out-of-bound access in uclamp Message-ID: References: <20210429152656.4118460-1-qperret@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Friday 30 Apr 2021 at 15:00:00 (+0200), Dietmar Eggemann wrote: > On 30/04/2021 14:03, Vincent Guittot wrote: > IMHO, this asks for > > min_t(unsigned int, clamp_value/UCLAMP_BUCKET_DELTA, UCLAMP_BUCKETS-1); Yep, that's what I have locally. > >> } > >> > >> static inline unsigned int uclamp_none(enum uclamp_id clamp_id) > > Looks like this will fix a lot of possible configs: > > nbr buckets 1-4, 7-8, 10-12, 14-17, *20*, 26, 29-32 ... > > We would still introduce larger last buckets, right? Indeed. The only better alternative I could see was to 'spread' the error accross multiple buckets (e.g. make the last few buckets a bit bigger instead of having all of it accumulated on the last one), but not sure it is worth the overhead. Suggestions are welcome though. > Examples: > > nbr_buckets delta last bucket size > > 20 51 +5 = 56 > > 26 39 +10 = 49 > > 29 35 +9 = 44 Yes the error can become worse in the relative sense with a large number of buckets, but again the max is 20 so we should be fine? Thanks, Quentin