Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp3905443pxb; Fri, 11 Feb 2022 10:17:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJy80K0au87V6+VfrBOVp3Ay1abE73RJgZ5aJI6sd4TpjVDYCoHUeJedjmUS4Nt9UV/VxrcE X-Received: by 2002:a63:8548:: with SMTP id u69mr2364602pgd.282.1644603447597; Fri, 11 Feb 2022 10:17:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644603447; cv=none; d=google.com; s=arc-20160816; b=Z2bJV1dZlSBtY6QwxbtsVdUM9/6r3R6MvYF0soiRkEzPO4hY0QYNplrr0F7+pbFNr/ qh7uARBRoV38DJRc0oayXTLruWfmohhPDK6gj1196hIl0n4b7yOWH3qEOtbk5CKIq2sS UR2Q1tqa8h+kCAF8bgbYCR+TdNtGVvo2SPgDKDaqMPr1jKXiZjxGJxQboj2Y8RjZ09qO i73OnoosrkM6QVf8XalV7l62dBjbdi5igIFCS/o9rDKbgjWHiiw4Ye7Dai1YwhpGp2aT DDgmNJhUY0slc7h8eqkgeaA5i38DfvnjQjC7OkC91/U1ra1WbkSbJvFosEyXMDQXYHiR 5nFg== 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=bwpOdgFQsH734At37yjdv4Nb0bvjgu3SgbDAbXyvUB4=; b=bLrrrl9T+BiU26sQHryrn1GyqD+/H1m8eS3aFwM/vwsEny83BPhT2g1IQ6EEyKbebT Ne+BGI6eChNQt+VFLrB9lthz0+Ats7mSIRl4op1YblXImAB7jhW8M2Z4ukvnWMtoySYa XSrh2IvBXaGD7od4mnJ5TQm5YObP5evzUhvUEuWgY/eRS5BiuDvdihDJ5XqK5cnUn74S gLnsQyCfmTkKvaAuXoFTEGHZWB5S6jOgM5Mg5vF6MekNQCAMfVTGQkuMQ6fTejqFeS3+ GZeclsQxV/0aZhLLosKIuC6SBjUJDxl7/Sq++MxBm8KcMjuQ4gOCLXjmy1lMVkrJOXVl qBQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=fI0xbKcd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bj9si25308677pgb.447.2022.02.11.10.17.13; Fri, 11 Feb 2022 10:17:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=fI0xbKcd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1344898AbiBJWWu (ORCPT + 99 others); Thu, 10 Feb 2022 17:22:50 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:49452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344868AbiBJWWt (ORCPT ); Thu, 10 Feb 2022 17:22:49 -0500 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41049117E for ; Thu, 10 Feb 2022 14:22:49 -0800 (PST) Received: by mail-lf1-x135.google.com with SMTP id f10so13026847lfu.8 for ; Thu, 10 Feb 2022 14:22:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bwpOdgFQsH734At37yjdv4Nb0bvjgu3SgbDAbXyvUB4=; b=fI0xbKcdzpA+8Va5155Mdfuw440giBRX8QLLR8+CLcUsOBdRYP4z5OQCb57mF1a8N6 t4s6l4rmrsyAyL1hj58kI/rAt3V/SV8/lSX51xzZhhhpDCqA409AECsie1YGy4IeHGLE +GVtYOgiHoGkj9QW0fe8XD1crWNgUuUWYkRV89jW49qmBY2DLgAVREQwkcLu3xvYYS9r kgPtnyKJRn30npoDJjXj4RnYDRe+JgEthHfR2mGk6dY1Mcg5fOQAR3nblzbsl3+Mdw+7 HYI9DpKPo3laQm7w7tXBN9WHS9Ql//I9J2NxCSL2J+brvwZ7zgOSXv0otFoAhUzNRBlM BG4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bwpOdgFQsH734At37yjdv4Nb0bvjgu3SgbDAbXyvUB4=; b=e60Fx/IkUsYiVkYRuRTK2Xzo5+4Z/6v1xRk/A9cB4yeFA3PUETLKpw1VRsf1gq8vt0 u1XVOXUB/gSH715pe1hDrnlVDS5c8uvIsQKVhW+yFv9uuwpPJ8sAFw84axA+GXJpMl33 6YPWpFl6g6N64RwcXW+OMur2oq9ZOOqg65pQ/MKENGl/bQ3SYnhcyjMDdA+FEmMPRE7K o7czx47d+K8oZlwIz1G98V8O1SaCH0N4mqpkVvFJSyI0ohYVy1tMJUviOi30QVeR2uHC 8LJD4agZmOzfeT3ajw/+fgVNlnxLNHR10fkl8bFZI12iI0XF0PmJYQNKJ6TRhAXUkuYa pXWQ== X-Gm-Message-State: AOAM532sgGJbx9RTvZd0Ahq+iWiY9xFp/+OvJO5TJ87cHk9o52pA4hnr pmKUsv1lhw3HvW8b1FMJvdrblH/9KU3sbAxazlm0WA== X-Received: by 2002:a05:6512:3e10:: with SMTP id i16mr6280877lfv.184.1644531767275; Thu, 10 Feb 2022 14:22:47 -0800 (PST) MIME-Version: 1.0 References: <20220210081437.1884008-1-shakeelb@google.com> <20220210081437.1884008-5-shakeelb@google.com> In-Reply-To: From: Shakeel Butt Date: Thu, 10 Feb 2022 14:22:36 -0800 Message-ID: Subject: Re: [PATCH 4/4] memcg: synchronously enforce memory.high To: Roman Gushchin Cc: Johannes Weiner , Michal Hocko , Chris Down , Andrew Morton , Cgroups , Linux MM , LKML Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 10, 2022 at 12:15 PM Roman Gushchin wrote: > [...] > > Has this approach been extensively tested in the production? > > Injecting sleeps at return-to-userspace moment is safe in terms of priority > inversions: a slowed down task will unlikely affect the rest of the system. > > It way less predictable for a random allocation in the kernel mode, what if > the task is already holding a system-wide resource? > > Someone might argue that it's not better than a system-wide memory shortage > and the same allocation might go into a direct reclaim anyway, but with > the way how memory.high is used it will happen way more often. > Thanks for the review. This patchset is tested in the test environment for now and I do plan to test this in production but that is a slow process and will take some time. Let me answer the main concern you have raised i.e. the safety of throttling a task synchronously in the charge code path. Please note that synchronous memory reclaim and oom-killing can already cause the priority inversion issues you have mentioned. The way we usually tackle such issues are through userspace controllers. For example oomd is the userspace solution for catering such issues related to oom-killing. Here we have a similar userspace daemon monitoring the workload and deciding if it should let the workload grow or kill it. Now should we keep the current high limit enforcement implementation and let it be ineffective for some real workloads or should we make the enforcement more robust and let the userspace tackle some corner case priority inversion issues. I think we should follow the second option as we already have precedence of doing the same for reclaim and oom-killing. thanks, Shakeel