Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp376511pxy; Fri, 30 Apr 2021 07:20:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkKvdKvK7+/7+eGjP0tHtIakZYX/MGEKwkC1dnqYOBOsHpsrIZPoWocaYpFXVXLhb5Fy+g X-Received: by 2002:a63:5214:: with SMTP id g20mr4971480pgb.158.1619792422675; Fri, 30 Apr 2021 07:20:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619792422; cv=none; d=google.com; s=arc-20160816; b=ogR2dzkeWrOVOXzu+yYMb/WSgV86QHtXi0eTPj40aFtqI7t9Q3BWZhdv00YvUPhaUe eHxSg9FNI6zxzRVPesb0UiXAZyXpWlTxmCzDVdJhXmoogWaRatErIngx4jHEQqWqW7ZA vNGaJ0P0kytZIxe6abZ7uXLQpUUJKFK2DYhNofD8J4bQCzFILY9YlAgRzs7af+5sELJS reh8gmOVe+2qcNtNEWc0bwWkYUNcHb2eZJS4pqy2Du1zW77EBJoOVgVMdF9czixCjA9T RQKn8WquyCVowvOqWJxC57M581gO3xv4YSvMTXfrXizrT78+l6nkAUg/AqAToIeokBkb 21HQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=tnW3u+GigqDOcp1lhiXKBs3xNXaI55kZNeSkREJXf/k=; b=GP/B1bIYMG5YUu+dah4od4zqTjGJrLm7TuoliMwXcglvIrsMSBEXWvqufy1CGu2ZUx YGgXh+D+hIGH4vEj1dp3rsd9u1V3/M+S9qo7Z+0Loi7/nE/eMwlzLSvVHBG2nnXBuEWZ ZQmsCYqhrMZGM+N9KMVNhS6dSy2zHYcUrzIlsqsOAEjAd0VX11Uv6+KxopsxpylU6P/N dmA5Cg1D1EndS0OOlk/50SdmU+NymvsRXwhE6oH5yjBGJsi/pPNkZEh0lFv/MM4/eW+J GC7OyjQULgcmDed4TUUoAqya4Qf24KqT3zh0G4Dw8auX6teKEwmu3DuicOCyiCv533Ol tUeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="nQ/HlXRm"; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l8si2187353pjy.152.2021.04.30.07.20.08; Fri, 30 Apr 2021 07:20:22 -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=@linaro.org header.s=google header.b="nQ/HlXRm"; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232743AbhD3OSA (ORCPT + 99 others); Fri, 30 Apr 2021 10:18:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232732AbhD3OR7 (ORCPT ); Fri, 30 Apr 2021 10:17:59 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5067DC06174A for ; Fri, 30 Apr 2021 07:17:11 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id x19so80010172lfa.2 for ; Fri, 30 Apr 2021 07:17:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=tnW3u+GigqDOcp1lhiXKBs3xNXaI55kZNeSkREJXf/k=; b=nQ/HlXRmGNwviRvr5FIrQM0OXGyOrjQ6CpWosdjYQs9ErMpgniG3YEPgEVIMgwJekQ r11KThVKnIC+TTb1zP6yePlQxV0cq4FFyZ+kmkJwNBnmivIY/QO8iFZnXx7SfjJRV/tc 7Hk+p0gPXQIQL2VO7MxD+Zxb0hqZxYFNvuL5tvg1T7vBM6eR/SnuZQvjRMFM/djtCDu/ A7z4pltuMTNgRTcbihUIbfxUHNEUmV9CKNd+0l1GR2olem99C1QPlpjxcdP63WYLQ5hh Q7dslKcxUVC33T2NjY2/eYY/xgg2rLxNKHPNUTr7Hoe48NYgv54kKVNxjy4cvRF0Z9K5 BXnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=tnW3u+GigqDOcp1lhiXKBs3xNXaI55kZNeSkREJXf/k=; b=klkVCzcpopt2n4lsaixgrilwDDiIXzFLkI6CvUu+RkuCoTIXCLDA4l4OzZ5EcOPCY8 3dYWq0UMiB0ojltkHHfrQFKe38bD7Qyu82ml8eroVUXHrNdywo/KMisoZZS/KahoH6wc f8oV2+zLaK2wG3XL/MFPCP+yQ56V54ZMbHdmrhYN6wU9bZ6qDe7WS7P5Bj2Azh7Db1Rd V6k/C2fI7oNANvZXOaqKeM/4f0FQ+39QhUiNg3O9uhczCVtIvUJGaNsTwAbMHFbp7JsC ic/XPnXJp1Fza1Lqcc+yqmDEtosg4FyIZdSJo7rO1FZd0hKi+LMMyvKkTa5qK6t9r6nh kyNA== X-Gm-Message-State: AOAM530zSAOLLTRCpTwseb6zn83XpAiMWM1Tqh9WImLq8wkCimEkSKjz S7zTm1Fmu6M5ANbJeWDPSF2O/agLpujsWf728hNWkg== X-Received: by 2002:ac2:4f03:: with SMTP id k3mr3443750lfr.254.1619792229818; Fri, 30 Apr 2021 07:17:09 -0700 (PDT) MIME-Version: 1.0 References: <20210429152656.4118460-1-qperret@google.com> In-Reply-To: From: Vincent Guittot Date: Fri, 30 Apr 2021 16:16:58 +0200 Message-ID: Subject: Re: [PATCH v2] sched: Fix out-of-bound access in uclamp To: Quentin Perret Cc: Dietmar Eggemann , 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 30 Apr 2021 at 15:14, Quentin Perret wrote: > > 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. I don't think it's 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