Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp2501616imn; Tue, 2 Aug 2022 05:28:16 -0700 (PDT) X-Google-Smtp-Source: AA6agR6PY1KVyAwZ129QxTT7oVSd9iucGJMAhe9EKdWxcaWReeCqcjArpqXKPGY8WXj44qdkBoyl X-Received: by 2002:aa7:de18:0:b0:43d:30e2:d22b with SMTP id h24-20020aa7de18000000b0043d30e2d22bmr18163494edv.224.1659443295837; Tue, 02 Aug 2022 05:28:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659443295; cv=none; d=google.com; s=arc-20160816; b=l3C+IChTyY2amiLPVuJWAyY1cNeT9Y7Hb8QFPdzMmt9ZwxyLeJ66sPJOn5ogjsiSFE 4U8pcCfcZIBoH7T7P2cYkqXZsLRnWQer+SdSfEj/sfp72gklaUXGQcGGn55PBHso8OJu 7M6sTAxjVpU0DewxMcujuDTkvFM+k5z2g6jf0JTtCw5aW1o3p0KPVxDCYDivgdM8jDVJ dsBFflIX46R7pYcMYGwGjFBUO6JjGkSIciuM7KmQNZncFSnoKrehbB0gSsIX2gX0/w5b t7/4K09uqoAKgAIwtdH6MkQ9zVbuMGsXQoLH+z6FCZsB9fmJRKMI4AmXto5RywciQZ5r sadg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=yNCOVJvTvXYjkbinC2wpPiVJJz4uAY9LW/GyhexozMg=; b=W8CnChBUTZqqBypHESgFp/jOJLNkATPf3yPkniiBnQFJUqYJVd+mOjAzrKm07bLVNj u4N4u6bcA0qXpKslgKeZd6IvOtuy3go4OPZnxQvGl5tNVVJ5sLCh1nMjmlBrzOGr+B+k 89vKOT0P4MT8+Idnu34iBHkgJcnZZtgVGztmordI/acrNVBg7dk4VJY7lZNjkmr3/UPV F1DlYoYn1ZrQBCUfTtUEyDz4D3AHtBZAhkuQ/EsD/JoLBsveFQc94ZPlBzxhKhUx+4UX pKI/exT1Dkq025ccRVb1Znj6J2LQyJ95x3+UUwEDm6LBMjC9D+zfNkVN7xp1K461FsGH 9PWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b="Y/f4ThdH"; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gs34-20020a1709072d2200b0073061fb686dsi7905140ejc.343.2022.08.02.05.27.50; Tue, 02 Aug 2022 05:28:15 -0700 (PDT) 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=@suse.com header.s=susede1 header.b="Y/f4ThdH"; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236673AbiHBMET (ORCPT + 99 others); Tue, 2 Aug 2022 08:04:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231208AbiHBMES (ORCPT ); Tue, 2 Aug 2022 08:04:18 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 878624AD7A; Tue, 2 Aug 2022 05:04:16 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 279431F936; Tue, 2 Aug 2022 12:04:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1659441855; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=yNCOVJvTvXYjkbinC2wpPiVJJz4uAY9LW/GyhexozMg=; b=Y/f4ThdH9BA3tZ6Mfyjhq2ZRwzYGOqQn6/SVYc6F8K9jwumW860ltxLGH9ZEdggr4RJgG8 qz88X9PpFtY85Nurju+9YH5zwoG6AKodu7DB1m8/wPvzc14p5eSmoX1H0n3UipW33jaIgb Rk2hmRcA9zN84E8AM/lNtlb70xzFAWI= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id F2D7E13A8E; Tue, 2 Aug 2022 12:04:14 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id +04/O74S6WKhNQAAMHmgww (envelope-from ); Tue, 02 Aug 2022 12:04:14 +0000 Date: Tue, 2 Aug 2022 14:04:14 +0200 From: Michal Hocko To: Zach O'Keefe Cc: linux-mm@kvack.org, Andrew Morton , linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, Axel Rasmussen , James Houghton , Hugh Dickins , Yang Shi , Miaohe Lin , David Hildenbrand , David Rientjes , Matthew Wilcox , Pasha Tatashin , Peter Xu , Rongwei Wang , SeongJae Park , Song Liu , Vlastimil Babka , Zi Yan , Andrea Arcangeli , Arnd Bergmann , Chris Kennelly , Chris Zankel , Helge Deller , Ivan Kokshaysky , "James E.J. Bottomley" , Jens Axboe , "Kirill A. Shutemov" , Matt Turner , Max Filippov , Minchan Kim , Patrick Xia , Pavel Begunkov , Thomas Bogendoerfer Subject: Re: [PATCH mm-unstable] mm/madvise: remove CAP_SYS_ADMIN requirement for process_madvise(MADV_COLLAPSE) Message-ID: References: <20220801210946.3069083-1-zokeefe@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham 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 Tue 02-08-22 02:48:33, Zach O'Keefe wrote: [...] > "mm/madvise: add MADV_COLLAPSE to process_madvise()" in the v7 series > ended with me mentioning a couple options, but ultimately I didn't > present a solution, and no consensus was reached[1]. After taking a > closer look, this is my proposal for what I believe to be the best > path forward. It should be squashed into the original patch. What do you think? If it is agreed that the CAP_SYS_ADMIN is too strict of a requirement then yes, this should be squashed into the original patch. There is no real reason to create a potential bisection headache by changing the permission model in a later patch. From my POV, I would agree that CAP_SYS_ADMIN is just too strict of a requirement. I didn't really have time to follow recent discussions but I would argue that the operation is not really destructive or seriously harmful. All applications can already have their memory (almost) equally THP collapsed by khupaged with the proposed process_madvise semantic. NOHUGEMEM and prctl opt out from THP are both honored AFAIU and the only difference is the global THP killswitch behavior which I do not think warrants the strongest CAP_SYS_ADMIN capability (especially because it doesn't really control all kinds of THPs). If there is a userspace agent collapsing memory and causing problems then it can be easily fixed in the userspace. And I find that easier to do than putting the bar so high that userspace agents would be unfeasible because of CAP_SYS_ADMIN (which is nono in many cases as it would allow essentially full control of other stuff). So from practical POV, risking an extended RSS is really a negligible risk to lose a potentially useful feature for all others. Just my 2c > Thanks again, > Zach > > [1] https://lore.kernel.org/linux-mm/Ys4aTRqWIbjNs1mI@google.com/ -- Michal Hocko SUSE Labs