Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A4E6C4361B for ; Wed, 16 Dec 2020 16:37:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8CF9E233E2 for ; Wed, 16 Dec 2020 16:37:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8CF9E233E2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id ADA206B0036; Wed, 16 Dec 2020 11:37:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A89176B0071; Wed, 16 Dec 2020 11:37:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9062D6B0073; Wed, 16 Dec 2020 11:37:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0236.hostedemail.com [216.40.44.236]) by kanga.kvack.org (Postfix) with ESMTP id 7336A6B0036 for ; Wed, 16 Dec 2020 11:37:24 -0500 (EST) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 306393630 for ; Wed, 16 Dec 2020 16:37:24 +0000 (UTC) X-FDA: 77599700808.13.trail68_1b0c4bb2742d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id EADF418140B67 for ; Wed, 16 Dec 2020 16:37:23 +0000 (UTC) X-HE-Tag: trail68_1b0c4bb2742d X-Filterd-Recvd-Size: 5935 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf33.hostedemail.com (Postfix) with ESMTP for ; Wed, 16 Dec 2020 16:37:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608136642; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LWXEDNXfhf3DYhncDS7I1+Bj0sNiRBAAEvL/AYyy2t8=; b=hPtTb//pgLpC7eMZB9gFLNNZFBD81ZjViB3MG7+1a/a09vrSVRGdQadZ5UraNJdZJBPl1R hNfFVV7pdIM2wnvwqFXmwOlHXZc27qc0vQAwOB6kfO56Ri12V9Kdj3P56WhT5Kx6+g1kFr NPIkm8jMyF5XcJrUYM2YMXYx14wDixI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-78-9XnbgFNsNlyGynRs32qxpQ-1; Wed, 16 Dec 2020 11:37:20 -0500 X-MC-Unique: 9XnbgFNsNlyGynRs32qxpQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 924DF1842158; Wed, 16 Dec 2020 16:37:08 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 896BD19809; Wed, 16 Dec 2020 16:37:08 +0000 (UTC) Received: from zmail23.collab.prod.int.phx2.redhat.com (zmail23.collab.prod.int.phx2.redhat.com [10.5.83.28]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 3A9214EEEE; Wed, 16 Dec 2020 16:37:08 +0000 (UTC) Date: Wed, 16 Dec 2020 11:37:07 -0500 (EST) From: Chunyu Hu Reply-To: Chunyu Hu To: Johannes Weiner Cc: linux-mm@kvack.org, guro@fb.com, akpm@linux-foundation.org Message-ID: <1730619355.62694721.1608136627736.JavaMail.zimbra@redhat.com> In-Reply-To: <20201215130638.GB379720@cmpxchg.org> References: <223826327.62466770.1608031937021.JavaMail.zimbra@redhat.com> <1273738630.62467759.1608032559889.JavaMail.zimbra@redhat.com> <20201215130638.GB379720@cmpxchg.org> Subject: Re: Question about admin_reserve_kbytes in GUESS mode MIME-Version: 1.0 X-Originating-IP: [10.72.12.72, 10.4.195.16] Thread-Topic: Question about admin_reserve_kbytes in GUESS mode Thread-Index: z+u1atrF1UXd4iCsb3gzKWyOWGmWWQ== X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=chuhu@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: ----- Original Message ----- > From: "Johannes Weiner" > To: "Chunyu Hu" > Cc: linux-mm@kvack.org, guro@fb.com, akpm@linux-foundation.org > Sent: Tuesday, December 15, 2020 9:06:38 PM > Subject: Re: Question about admin_reserve_kbytes in GUESS mode > > On Tue, Dec 15, 2020 at 06:42:39AM -0500, Chunyu Hu wrote: > > Hello experts, > > > > I find admin_reserve_kbytes is not working as documented since > > commit 8c7829b04c523cdc(mm: fix false-positive OVERCOMMIT_GUESS failures). > > > > Before that, available free pages are used to determine the allocation > > check, and admin_reserve_kbytes > > was honored in the default GUESS over_commit mode. While after that commit, > > admin_reserve_kbytes > > is not honored in default mode any more. This looks like break the sysctl > > usage? > > > > Documentation/admin-guide/sysctl/vm.rst: > > > > admin_reserve_kbytes > > ==================== > > > > The amount of free memory in the system that should be reserved for users > > with the capability cap_sys_admin. > > > > admin_reserve_kbytes defaults to min(3% of free pages, 8MB) > > > > That should provide enough for the admin to log in and kill a process, > > if necessary, under the default overcommit 'guess' mode. > > Thanks for the report. > > Can you elaborate on your usecase a bit? How you rely on the knob, and > how it's not working properly now? Thanks for the reply! We drafted a test according to the document. The step is something like: In default GUESS overcommit memory mode: Test#1: total_memory=$(grep MemTotal /proc/meminfo | awk '{print $2}') swapoff -a echo ${total_memory} > /proc/sys/vm/admin_reserve_kbytes useradd ark_test su ark_test -c 'ls -al ~' <------------------ We expect fail here, now it succeeds. Test#2 (continue with Test#1) sysctl -w vm.drop_caches=3 free_memory=$(grep MemFree /proc/meminfo | awk '{print $2}') sysctl -w vm.admin_reserve_kbytes=$((free_memory-512*1024)) # Leave 512M memory su ark_test -c 'memhog -r10 1g' <----------- consume 1G memory, we expect it fail, now it succeeds. > > It would be easy enough to this check back to the simplified formula, > I'm just having some trouble picturing how it would be useful. The thing described in document is useful, that we can config to leave some memory to cap_sys_admin user. > > The knob never (not since git, anyway) behaved the way it's documented > here. We don't track total virtual memory; instead the checks apply to > individual allocations. So it was never true that we reserve 3% of RAM > for admins. Rather, the biggest single mmap() request an admin could > do was 100% of RAM, whereas for unprivileged users it was 97% of RAM. > But you could always do two or more requests of that size in a row > anyway. It's not clear to me that this is a meaningful distinction. I need sometime to understand what it means by 'in a row', you mean parallel allocation that more than one threads do mmap() at same time? -- Regards, Chunyu Hu