Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4718176pxv; Tue, 27 Jul 2021 14:42:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJya8htbcA8I4XPZnPcE4KzrEt+7HYb89dkOWSbEXAojh8UEpXG3YC7pGQ+HY4so0dw1UprM X-Received: by 2002:a5e:9513:: with SMTP id r19mr20627167ioj.156.1627422153904; Tue, 27 Jul 2021 14:42:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627422153; cv=none; d=google.com; s=arc-20160816; b=xSfrmbeQyd1HEQXvVrd6xTc39c9csb1HJGKHoEFEbR44X8B2zSJzSqPPWSGAS4FXse vr6pqVI12qH3rLYHML58LE4P9uzRHhvqX15bmEpCMwbQYeRbiCTN7XATP/uPLhnov92k M3qgJ3bl1saVgAC5UL7Ej+zBGXl05f5yiMK8sbDcNmc3eXPo4IgWbM9JXEDPqE5l/q2p Hmq6YE53bK/nwE8SbkVdzBFF9N6/wBAT4VMvmH5xj9nJFzjxv/bMNPGBEyummB6gSzd/ ORe4SK0FoJhUiSAqzvf2IAdK3MHpof1Q32Mgke6krNJSFnCgJNintYpl1OkwWneQAKRv zjjw== 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=586qQ0VfqS2t1FgawENmqvW9B/cgMqgnCEiHKLyzI/E=; b=xUWajuMstHaohBMI7yn4V9fhfxSsnCwiB03gPxkFwwMmybS9JqBnHitQB03771ihyE uBfcYGeCkrBap7siwraZtHk7jYcHs1mvTfCi6HO0X9izG8+0ddOGIbPaJpNEJn2LtS0S IIFFAmGTVwbt9nTTvpsti0gVNg0Vb8nGrc2z5J2HYD3QSvBZZs7WRkedqjoDlUMnDaRV SrZ/u0Tu3faHAs3qY/4b5syxlel4BDCYYo7Ufec85HYLKX3seW+BwrjTMhrETWxg6Fsc AK1ke7iUh49diNU69CXTfZGcWqOdbkaDfOJIDlD38/imMeFNwfM0G4FiKbwGAz3lZgZJ wSLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="u1/MVJO4"; 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 t2si4062691iop.79.2021.07.27.14.41.58; Tue, 27 Jul 2021 14:42:33 -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="u1/MVJO4"; 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 S232002AbhG0Vjk (ORCPT + 99 others); Tue, 27 Jul 2021 17:39:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231339AbhG0Vji (ORCPT ); Tue, 27 Jul 2021 17:39:38 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33939C061765 for ; Tue, 27 Jul 2021 14:39:36 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id h2so24337834lfu.4 for ; Tue, 27 Jul 2021 14:39:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=586qQ0VfqS2t1FgawENmqvW9B/cgMqgnCEiHKLyzI/E=; b=u1/MVJO4zcfaei7PD7eWb+709nz15VrWARci7ePDMDFolJNUERP2wsbjom+4NbVKF7 ssCxzxA0a2UMxu67QqmKkzf8Ut6ydxeIlIqw2blw57FpMzpCZ3PC+AX7TZdUAx0tipyl G8luFgvQvburMncuoSBNoiciSrzOHj4b5hjw5HfttQCJX69lVCqpmjGkRnGShNJwduXw Zh8TM0wbJKBTwe0RiYKQ6DlcLgR+hq+p9L+JSK8/8r1bCXiy6mY+G/ZI55irmnQDLRxC ZeISUoXD1z4L5Wyc48m90u3UbQaFELITPkCenCYevX5lJ/OgtMDHFVm6vd5w9iw29W+4 Bw0g== 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=586qQ0VfqS2t1FgawENmqvW9B/cgMqgnCEiHKLyzI/E=; b=URYX/D7OjksrbEQ7CWETW+LahX7Q7bxrx+6YHRhc/sdRoU4buRODBpjvnF6K+i7kcK 1y5Mziff/5NEQR49H8E9YIXGoWhNUutx2/qlZU9XI8tb13GDqIkO1nCUdmnZvnVPRQ5w JL//inzAFbOPg9yktLWmBRYxpapWJKabDcDpUXOYfYofb0F6cXBSo2m9UVzPaDD95X6E K5cu2g7ixp5f+uqhvn4N6bZAAvnfGkyRxgCKe6+Pya8ofl3sdhDpg+WSHzAjqataTba9 1Y5ckSMyvmqBFUQ6U9ZqG3czimHEmjslzYiJN+xDYRvsftrNSVtH6KUF4uph29PaCDK1 Br5w== X-Gm-Message-State: AOAM533HCep7sHW574cM8QimPeUn54rheQAjU4VP+5yh09FXU7EwndTj wgOgyB4vDvixjtd3085VzaWDgyssocsiJPXtFo0yBQ== X-Received: by 2002:a19:ae0f:: with SMTP id f15mr18055453lfc.117.1627421974281; Tue, 27 Jul 2021 14:39:34 -0700 (PDT) MIME-Version: 1.0 References: <6f21a0e0-bd36-b6be-1ffa-0dc86c06c470@virtuozzo.com> <56e31cb5-6e1e-bdba-d7ca-be64b9842363@virtuozzo.com> In-Reply-To: <56e31cb5-6e1e-bdba-d7ca-be64b9842363@virtuozzo.com> From: Shakeel Butt Date: Tue, 27 Jul 2021 14:39:23 -0700 Message-ID: Subject: Re: [PATCH v7 02/10] memcg: enable accounting for pollfd and select bits arrays To: Vasily Averin Cc: Andrew Morton , Cgroups , Michal Hocko , Johannes Weiner , Vladimir Davydov , Roman Gushchin , Alexander Viro , linux-fsdevel , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 26, 2021 at 10:33 PM Vasily Averin wrote: > > User can call select/poll system calls with a large number of assigned > file descriptors and force kernel to allocate up to several pages of memory > till end of these sleeping system calls. We have here long-living > unaccounted per-task allocations. > > It makes sense to account for these allocations to restrict the host's > memory consumption from inside the memcg-limited container. > > Signed-off-by: Vasily Averin > --- > fs/select.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/fs/select.c b/fs/select.c > index 945896d..e83e563 100644 > --- a/fs/select.c > +++ b/fs/select.c > @@ -655,7 +655,7 @@ int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp, > goto out_nofds; > > alloc_size = 6 * size; > - bits = kvmalloc(alloc_size, GFP_KERNEL); > + bits = kvmalloc(alloc_size, GFP_KERNEL_ACCOUNT); What about the similar allocation in compat_core_sys_select()? Also what about the allocation in poll_get_entry()? > if (!bits) > goto out_nofds; > } > @@ -1000,7 +1000,7 @@ static int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds, > > len = min(todo, POLLFD_PER_PAGE); > walk = walk->next = kmalloc(struct_size(walk, entries, len), > - GFP_KERNEL); > + GFP_KERNEL_ACCOUNT); > if (!walk) { > err = -ENOMEM; > goto out_fds; > -- > 1.8.3.1 >