Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3286155lfo; Mon, 23 May 2022 00:43:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7coZYUgaESAPy2/y/aGtL9RCg1QJfgjFWStif+6J83VPhX9Fq0c/F0Gv2ROeKxlvvUiX6 X-Received: by 2002:a05:6a00:7d6:b0:518:9fa0:7dc with SMTP id n22-20020a056a0007d600b005189fa007dcmr4061616pfu.36.1653291838582; Mon, 23 May 2022 00:43:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653291838; cv=none; d=google.com; s=arc-20160816; b=GSircYV9hoCH+lD/HqiTtZ9zLKDFGALroCKK1A7WZMLCVs9WZ3iL3YzjOiIwXgLfG2 Hi6lmLdXRXZfB5HkfouOS7fJTjpj2V8VVHb6jnNWSiUs6q1xScd7bvSGWaqcBI+0eYzf BLjWC6MyPwmOq1rkHR2NkIaqXVi6bGTkwBE8vs6NL8/sUqT/xKKVetJgJhvGRBbSZ0Ot c7HukWG7JsNsuHiMzeCM5m8rY0f85zurYO6Q8kivZ+bAHrFbe/OqG2caSPAQoVPZljwP 6yxYU+1UPz7YDlNLJ6MI4yNTqJMn0y0xkRZXF8NPrl99P5GK+QNV/9Cmzlfn8eKLrN0q j6kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :from:references:cc:to:content-language:user-agent:mime-version:date :message-id:dkim-signature:dkim-signature; bh=C55mA7Gcdj6mV5Wh6tOYntZbioSd1fH8dLwGmuS/9aw=; b=Bxgf6dMkNEVF8NAyC+fNos5CDco0stfPTSGc0Oh7S/yYhykX8gZ+++Wao6Y8hSIwYg XpfsHrzi6Ib2kD6lAQ3rRwhAFVyoJYfXhAy895YQRyPKTW5KUm7gMWJKQxpez7SCYdu3 RywIordaS3uefrrSn0u57BpIW6GqwCTsTOO8UEaOzOTsb8qGZdXsl2hy4JFkhPRLBLds 32NFHEvXQ3zF+l5ssHokdtul54KZXtHsTJE21ejKFdBVQXg/okr6vsPG1CjvMKbdOsPs 37qC9v/fp19BEPm7g6u551o4XrN6TvHRHSZnAOS/Qas9YjJLAoCbEQ4Si3cDeCtx8hgm EN9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=h6D0ikPK; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=EM51IkLU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q14-20020a056a00084e00b0050d429bb67esi13716082pfk.82.2022.05.23.00.43.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 00:43:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=h6D0ikPK; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=EM51IkLU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0532353B65; Sun, 22 May 2022 23:50:43 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349196AbiETMXM (ORCPT + 99 others); Fri, 20 May 2022 08:23:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349273AbiETMXC (ORCPT ); Fri, 20 May 2022 08:23:02 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B00316498F for ; Fri, 20 May 2022 05:23:01 -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-out1.suse.de (Postfix) with ESMTPS id B5BF621BD8; Fri, 20 May 2022 12:22:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1653049379; h=from:from:reply-to: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=C55mA7Gcdj6mV5Wh6tOYntZbioSd1fH8dLwGmuS/9aw=; b=h6D0ikPKhhJQ2bvLnSJWEQNqQ/s1NiEdAOK4vk3m/DR9/sNKkX/hZ2xRsaNmAhib7rypXR 7OzYKcPQG55MzIw2/LniYnQNChudwQ7wpP6zDuAkvlVWSMlGaMcxwmcdS+usHfrBjeCCty x26oNmmTKBvysdApyUmNqwlmO0GeUy8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1653049379; h=from:from:reply-to: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=C55mA7Gcdj6mV5Wh6tOYntZbioSd1fH8dLwGmuS/9aw=; b=EM51IkLUUliO6PAFaRMUPUHvBxvMqTA4Aag1UCKGtUvCjCmVuQAjiGqg6Dc7yxrn/mkvUz ziJtrOh8Hc/uFjBg== 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 8125F13AF4; Fri, 20 May 2022 12:22:59 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id DMqzHiOIh2JpRAAAMHmgww (envelope-from ); Fri, 20 May 2022 12:22:59 +0000 Message-ID: <408b79d9-e96a-b961-1565-93bf11e54909@suse.cz> Date: Fri, 20 May 2022 14:22:59 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Content-Language: en-US To: "Kirill A. Shutemov" , =?UTF-8?Q?Jakub_Mat=c4=9bna?= Cc: linux-mm@kvack.org, patches@lists.linux.dev, linux-kernel@vger.kernel.org, mhocko@kernel.org, mgorman@techsingularity.net, willy@infradead.org, liam.howlett@oracle.com, hughd@google.com, riel@surriel.com, rostedt@goodmis.org, peterz@infradead.org, david@redhat.com References: <20220516125405.1675-1-matenajakub@gmail.com> <20220517164403.nabrtbkezex7uof4@box.shutemov.name> From: Vlastimil Babka Subject: Re: [RFC PATCH v3 0/6] Removing limitations of merging anonymous VMAs In-Reply-To: <20220517164403.nabrtbkezex7uof4@box.shutemov.name> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE 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 5/17/22 18:44, Kirill A. Shutemov wrote: > On Mon, May 16, 2022 at 02:53:59PM +0200, Jakub Matěna wrote: >> This is a series of patches that try to improve merge success rate when >> VMAs are being moved, resized or otherwise modified. >> >> Motivation >> In the current kernel it is impossible to merge two anonymous VMAs >> if one of them was moved. That is because VMA's page offset is >> set according to the virtual address where it was created and in >> order to merge two VMAs page offsets need to follow up. >> Another problem when merging two faulted VMA's is their anon_vma. In >> current kernel these anon_vmas have to be the one and the same. >> Otherwise merge is again not allowed. >> There are several places from which vma_merge() is called and therefore >> several use cases that might profit from this upgrade. These include >> mmap (that fills a hole between two VMAs), mremap (that moves VMA next >> to another one or again perfectly fills a hole), mprotect (that modifies >> protection and allows merging with a neighbor) and brk (that expands VMA >> so that it is adjacent to a neighbor). >> Missed merge opportunities increase the number of VMAs of a process >> and in some cases can cause problems when a max count is reached. > > Hm. You are talking about missed opportunities, but do you know any > workload that would measurably benefit from the change? We do know about a workload that originally inspired this investigation of feasibility, but it's proprietary and will take a while to evaluate the benefits there. We did hope that a public RFC could lead to discovering others that also have a workload that would benefit, and might currently use some userspace workarounds due to the existing limitations. > The changes are not trivial. And rmap code is complex enough as it is. True, it was one of the goals, to see how complex exactly it would be. And an opportunity to better document related parts of mm as part of the master thesis :) > I expect common cases to get slower due to additional checks that do not > result in more merges. Stats so far have shown that merges that this enables did happen, only a few percent cases didn't. Of course for many workloads the extra merges will not bring much benefit. One possibility is to introduce an opt-in mode (prctl or madvise?) for workloads that know they would benefit. > I donno, the effort looks dubious to me as of now. At least patches 1+2 could be considered immediately, as they don't bring extra complexity. A related issue which was brought to our attention is that current mremap() implementation doesn't work on a range that spans multiple vma's. The multiple vma's may be result of the current insufficient merging, or otherwise. And it's tedious for userspace to discover the boundaries from /proc/pid/maps to guide a mremap() vma by vma. More sucessful merging would thus help, but it should be also possible to improve the mremap() implementation, which shouldn't be as complex...