Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9903CC7EE2E for ; Mon, 27 Feb 2023 17:50:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229868AbjB0RuQ (ORCPT ); Mon, 27 Feb 2023 12:50:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229542AbjB0RuO (ORCPT ); Mon, 27 Feb 2023 12:50:14 -0500 Received: from mail-yw1-x112d.google.com (mail-yw1-x112d.google.com [IPv6:2607:f8b0:4864:20::112d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4504A83E8 for ; Mon, 27 Feb 2023 09:50:13 -0800 (PST) Received: by mail-yw1-x112d.google.com with SMTP id 00721157ae682-536bbe5f888so197834597b3.8 for ; Mon, 27 Feb 2023 09:50:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=NoJU+P+wk0oP4uOQVAulVzE7C+CLPILBxmnJLRQCZ04=; b=PiMWHRJUpVelTbxf7LJVGiZYvQnIU3y8Qacrg9vzNxq2j3lwg+vo/OZkyZllDmIpIh KIwD10qtsZtlacmxcJAvI+IOxTl2OMd78qzCYpADGpGkbHYgF8JTH1OAJS2gxfaqbva1 Ampsmh7LW/cdt1IMF583Yq0R8mDIK3gD4fFaN5xq9N/CYkmKy57ydA+dWMrW9VQ4K9Vi twbl3C44EY4+K2+vd38kHJQvyew+ugfDirLXryujzn+4EUbS4pNPZQFTd80oBNSB1eOD EhoiujTNyy6Q63JD98dL4xAXk89mwbViAXrxemw1QVXvzvpjnFD0DQZTJ//sW7PGky6h KG2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=NoJU+P+wk0oP4uOQVAulVzE7C+CLPILBxmnJLRQCZ04=; b=X6VrVGXUKB9hw/0vrE7H5Ng4/Hr5ZnSFYU4RGXQXdUlxFrCLj0eKliSfjro7bxK34A 1QOIPnD91QMiSKvX5DLMrEiL6PuNHQqJQ8YT6/UbjvCWjCiZOqa+kSxFH6t6u56GpSzP QWVeSFb6slxLjDULb2pUQAwUwSWcjv110NsfL03pPp/qrWajvkr/MK0V0F7DlorOESHP q8g1YxsILZxhlOlEHOAAsLfxh5B9Hg/R3suLqoUA3b7V2Aqt0gWsIn1ArvjuBcY/Pt62 VjmbOcDPO08IhTF29A/wdyG0nmdFpVd8ZjkQK5LKMhj3TI568MEDykyJcxU4rrO5LY1y Vx3g== X-Gm-Message-State: AO0yUKX7kh8///JaPwNihegSWjhdD2k3y7ihpM9AczUDwLzjDW0f/ifC FzUkK3u66mDotAltW21ZIDEY0kdy9mwdXCZMy9Cgjg== X-Google-Smtp-Source: AK7set+AuUEVky3TlKUD481gMrdm00yhbolbqC6ZjtveZ4fmE3p+G7HBX+5fhoi8eN6gwoWKepOXmPldg78dfHdQaV4= X-Received: by 2002:a81:ad27:0:b0:533:9d49:f9c9 with SMTP id l39-20020a81ad27000000b005339d49f9c9mr11022028ywh.0.1677520212213; Mon, 27 Feb 2023 09:50:12 -0800 (PST) MIME-Version: 1.0 References: <15cd8816-b474-0535-d854-41982d3bbe5c@quicinc.com> <82406da2-799e-f0b4-bce0-7d47486030d4@quicinc.com> In-Reply-To: From: Suren Baghdasaryan Date: Mon, 27 Feb 2023 09:49:59 -0800 Message-ID: Subject: Re: [PATCH] psi: reduce min window size to 50ms To: Michal Hocko Cc: Sudarshan Rajagopalan , David Hildenbrand , Johannes Weiner , Mike Rapoport , Oscar Salvador , Anshuman Khandual , mark.rutland@arm.com, will@kernel.org, virtualization@lists.linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, Trilok Soni , Sukadev Bhattiprolu , Srivatsa Vaddagiri , Patrick Daly , johunt@akamai.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 27, 2023 at 5:34 AM Michal Hocko wrote: > > On Fri 24-02-23 13:07:57, Suren Baghdasaryan wrote: > > On Fri, Feb 24, 2023 at 4:47 AM Michal Hocko wrote: > > > > > > On Tue 14-02-23 11:34:30, Suren Baghdasaryan wrote: > > > [...] > > > > Your suggestion to have this limit configurable sounds like obvious > > > > solution. I would like to get some opinions from other maintainers. > > > > Johannes, WDYT? CC'ing Michal to chime in as well since this is mostly > > > > related to memory stalls. > > > > > > I do not think that making this configurable helps much. Many users will > > > be bound to distribution config and also it would be hard to experiment > > > with a recompile cycle every time. This seems just too impractical. > > > > > > Is there any reason why we shouldn't allow any timeout? Shorter > > > timeouts could be restricted to a priviledged context to avoid an easy > > > way to swamp system by too frequent polling. > > > > Hmm, ok. Maybe then we just ensure that only privileged users can set > > triggers and remove the min limit (use a >0 check)? > > This could break existing userspace which is not privileged. I would > just go with CAP_SYS_NICE or similar with small (sub min) timeouts. Yeah, that's what I meant. /proc/pressure/* files already check for CAP_SYS_RESOURCE (https://elixir.bootlin.com/linux/latest/source/kernel/sched/psi.c#L1440) but per-cgroup pressure files do not have this check. I think the original patch which added this check (https://lore.kernel.org/all/20210402025833.27599-1-johunt@akamai.com/) missed the cgroup ones. This should be easy to add but I wonder if that was left that way intentionally. CC'ing the author. Josh, Johannes is that inconsistency between system pressure files and cgroup-specific ones intentional? Can we change them all to check for CAP_SYS_RESOURCE? > > > > Btw. it seems that there is is only a limit on a single trigger per fd > > > but no limits per user so it doesn't sound too hard to end up with too > > > much polling even with a larger timeouts. To me it seems like we need to > > > contain the polling thread to be bound by the cpu controller. > > > > Hmm. We have one "psimon" thread per cgroup (+1 system-level one) and > > poll_min_period for each thread is chosen as the min() of polling > > periods between triggers created in that group. So, a bad trigger that > > causes overly aggressive polling and polling thread being throttled, > > might affect other triggers in that cgroup. > > Yes, and why that would be a problem? If unprivileged processes are allowed to add new triggers then a malicious process can add a bad trigger and affect other legit processes. That sounds like a problem to me. Thanks, Suren. > -- > Michal Hocko > SUSE Labs