From mboxrd@z Thu Jan 1 00:00:00 1970 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A079C5DF62 for ; Wed, 26 Jan 2022 01:42:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 59DE06B0075; Tue, 25 Jan 2022 20:42:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 54D4E6B007B; Tue, 25 Jan 2022 20:42:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3EE4D6B007D; Tue, 25 Jan 2022 20:42:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0002.hostedemail.com [216.40.44.2]) by kanga.kvack.org (Postfix) with ESMTP id 2CE4A6B0075 for ; Tue, 25 Jan 2022 20:42:05 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id BD1D4183DBF33 for ; Wed, 26 Jan 2022 01:42:04 +0000 (UTC) X-FDA: 79070737368.16.BB28560 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by imf20.hostedemail.com (Postfix) with ESMTP id 51D9A1C000E for ; Wed, 26 Jan 2022 01:42:04 +0000 (UTC) Received: by mail-pj1-f51.google.com with SMTP id n16-20020a17090a091000b001b46196d572so4643127pjn.5 for ; Tue, 25 Jan 2022 17:42:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:in-reply-to:message-id:references :mime-version; bh=jcmJBIHPwHjznYtDDk6Boea8e5KryTYO/GlCBZebjjA=; b=LOwzPM1SoqHGYd2SxQWQ8hws35Uh7wvjYPKYB5Vh9boIA9KB527XTHrptuNGzj2Uh2 9Gzd2tVgY2UZyHU48NroEeNTAWCywS2x9INKK+1IK5i9lsAZCMTaZzmA4LWILH3HimDC wfJh0+pz/FeSZ5hr/mvz+1AhQjAETXbg8E1NLIjPZ3vvoGZraatWgm9+Q68bDIl3wiqD SLu42ZcdTKzdWP5hUXqLGNflzredT1NSUsJ4f59mxVCJcXFpR9mdl3eWf1mYPJ+Xksqi K+VDa96hrD3GXv6dOyFhbbKx4sZ70jFhGbqt02q98tBDPsDVYbBv/CWJ9vhk+cSWFwOF 5BDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:mime-version; bh=jcmJBIHPwHjznYtDDk6Boea8e5KryTYO/GlCBZebjjA=; b=0ss+YA0jqvtHoD6TPkAZn4hSjrgXjuUmfStvz1iDingAFs4gO9y7zT9xQ7O3W9aj6B fZwKpxKH9bAUatoNL2LbNx0RMqBXfx478UZiHdLLHFdfWgG7NX/dJCZg7MROh/f7HBP5 d3yyYyKJMU/CSH7J5IoNXC9qYt6TwVH9XGw66kjncMdIuPTwd8mCJHU/CjHy3VW2Y3Cf xtUpp74mSfTEvNmKz1r2k4y7J16yxTw8AbK+32WZy+7z6LV4MwptE+J3Qn07zW1Qf6Hb tra9tTo1HTa0JrWrCBb/fjGt2qpXErW7n9yteYFOOI32Dik4DIpVbt6pCi+QTA1FU9HY M3sA== X-Gm-Message-State: AOAM530X/ehqDo6eP32hayin368GiJ+qw4of8wSuoWtrELRJNrkx0vvT 7TQwxs0h713FrqReq39nrFyQ1A== X-Google-Smtp-Source: ABdhPJx+SJ7RolZNSesy0gS5Wemy2a8+KnwlbY3SOtckqU1aE7x7sgZI+kUHGuvyC4nw0We4h+a5Vg== X-Received: by 2002:a17:90a:aa95:: with SMTP id l21mr6393110pjq.207.1643161322880; Tue, 25 Jan 2022 17:42:02 -0800 (PST) Received: from [2620:15c:29:204:6f7a:fc02:d37c:a8b0] ([2620:15c:29:204:6f7a:fc02:d37c:a8b0]) by smtp.gmail.com with ESMTPSA id nv13sm1561492pjb.18.2022.01.25.17.42.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 17:42:01 -0800 (PST) Date: Tue, 25 Jan 2022 17:42:01 -0800 (PST) From: David Rientjes To: Shakeel Butt cc: Jens Axboe , Pavel Begunkov , Andrew Morton , Linux MM , LKML , io-uring@vger.kernel.org Subject: Re: [PATCH] mm: io_uring: allow oom-killer from io_uring_setup In-Reply-To: Message-ID: References: <20220125051736.2981459-1-shakeelb@google.com> <2bec4db-1533-2d39-77f9-bf613fc262d9@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Rspamd-Queue-Id: 51D9A1C000E X-Rspam-User: nil Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=LOwzPM1S; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf20.hostedemail.com: domain of rientjes@google.com designates 209.85.216.51 as permitted sender) smtp.mailfrom=rientjes@google.com X-Stat-Signature: x18rxqzgwfo1xcztxacmhmtyer8ytz9y X-Rspamd-Server: rspam08 X-HE-Tag: 1643161324-657539 X-Bogosity: Ham, tests=bogofilter, spamicity=0.001859, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, 25 Jan 2022, Shakeel Butt wrote: > > > On an overcommitted system which is running multiple workloads of > > > varying priorities, it is preferred to trigger an oom-killer to kill a > > > low priority workload than to let the high priority workload receiving > > > ENOMEMs. On our memory overcommitted systems, we are seeing a lot of > > > ENOMEMs instead of oom-kills because io_uring_setup callchain is using > > > __GFP_NORETRY gfp flag which avoids the oom-killer. Let's remove it and > > > allow the oom-killer to kill a lower priority job. > > > > > > > What is the size of the allocations that io_mem_alloc() is doing? > > > > If get_order(size) > PAGE_ALLOC_COSTLY_ORDER, then this will fail even > > without the __GFP_NORETRY. To make the guarantee that workloads are not > > receiving ENOMEM, it seems like we'd need to guarantee that allocations > > going through io_mem_alloc() are sufficiently small. > > > > (And if we're really serious about it, then even something like a > > BUILD_BUG_ON().) > > > > The test case provided to me for which the user was seeing ENOMEMs was > io_uring_setup() with 64 entries (nothing else). > > If I understand rings_size() calculations correctly then the 0 order > allocation was requested in io_mem_alloc(). > > For order > PAGE_ALLOC_COSTLY_ORDER, maybe we can use > __GFP_RETRY_MAYFAIL. It will at least do more aggressive reclaim > though I think that is a separate discussion. For this issue, we are > seeing ENOMEMs even for order 0 allocations. > Ah, gotcha, thanks for the background. IIUC, io_uring_setup() can be done with anything with CAP_SYS_NICE so my only concern would be whether this could be used maliciously on a system not using memcg, but in that case we can already fork many small processes that consume all memory and oom kill everything else on the system already.