Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp697542pxm; Fri, 25 Feb 2022 17:34:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJwoTTW13i8hE5yzZB7x9lEiwLcVQpKvPoBcWNbK/VW5ZPkJF6s5Osco2Du6lYh9JHPHPZnB X-Received: by 2002:a63:e543:0:b0:373:efe3:6f46 with SMTP id z3-20020a63e543000000b00373efe36f46mr8459586pgj.183.1645839280472; Fri, 25 Feb 2022 17:34:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645839280; cv=none; d=google.com; s=arc-20160816; b=mbxif8YvNemFr3UlHthTQgrWuaSimPfhvnIS6wGJQH1v15WovdIhwT4n4KqNSuEOoX 4WaRDUpk3y9qDzBWfGnwJ/BLRWq+W6fxCSdCkZLqwS2H4M+2Q0mt+JZPy/ofWoKT/OvD 20Ej+zZWCdzUtefa5jcACsq5M0WiyYG4SS0rxhc4847kwXV10KQJaAoVlOi4BE7fRNnd LEEvjUwuq/KZFBU7fbrSl8mpsKNLNZ/TfYy8ANzmPR6SSX3BKbUAUlbcm6thI15N8IZ3 Jl/mX0IpnG3NR+NhucxXHxT7Y/JQtnLfa0SR9KLvUbSS1RgUb9GPPmyoYCbnhvswjxGJ Ta/w== 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=ahs8xAWJnTUeFm8mayyoprYbMUR2xi8uypk5DkAI7Jk=; b=rFA+zjfK5MGEuPrFIk9d+81lR4kvkOMxM9lfL7c3y88yC5ALdrcmVBf8YflcNobtUE dDDDHvdC6/Ju7uoQPJ0OznY9T+46XrlBWG/6+0hyWEi22wRbxv5E0xHfWZHJsAS9Nuxf dk42eXfrq66bWKqE18O9ULPtIjOW86L5i79g/xzK3Q/bqb+m1RgsEI5BTOLvX+CbilNf XVwLmdl7OxiVi7q6P9ny3AjuWkDd8624t8SgMlnESe1Yq51G6mDnPYH8HBTcBIYGFE/B a2EKBHT3t9zHncS6/ynZva8P7pivKmTJ+NdEk3VtUbNG3Ta6GWMBmAo33/JnrsU8KIN2 EHbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=li02W+4C; dkim=neutral (no key) header.i=@suse.cz; 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 s12-20020a17090a5d0c00b001b9975f431esi8379212pji.158.2022.02.25.17.34.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Feb 2022 17:34:40 -0800 (PST) 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=li02W+4C; dkim=neutral (no key) header.i=@suse.cz; 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 AA2EE1CA5FD; Fri, 25 Feb 2022 17:29:25 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239687AbiBYKkX (ORCPT + 99 others); Fri, 25 Feb 2022 05:40:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239691AbiBYKkW (ORCPT ); Fri, 25 Feb 2022 05:40:22 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F14868F9E for ; Fri, 25 Feb 2022 02:39:50 -0800 (PST) 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 EA49221114; Fri, 25 Feb 2022 10:39:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1645785588; 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=ahs8xAWJnTUeFm8mayyoprYbMUR2xi8uypk5DkAI7Jk=; b=li02W+4CVQaEnfPXLfd+rNHAW9NiRUJ9keX1sztepXJ/9vi+6SoZyAH2OWSHt7B5mOfMmz VJnxpZMKAni6EBeJl5tSQa2rPsjtxn8ZoLudn6rGxaa2WS5rooI06DkuJaWgJRpLMRTOeE Y8Djg+789HA/LUhOrfzyM+6sj5wOy8s= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1645785588; 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=ahs8xAWJnTUeFm8mayyoprYbMUR2xi8uypk5DkAI7Jk=; b=Dyg22q9OODbCq/87IZuFouV9ej6aWXRNegKPYGtW3hn1IVrSH175qsaJEENlKapHVCfwdX sQpMuw7bxCQHrzCw== 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 B721713ACB; Fri, 25 Feb 2022 10:39:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id r+IELPSxGGJ4eAAAMHmgww (envelope-from ); Fri, 25 Feb 2022 10:39:48 +0000 Message-ID: Date: Fri, 25 Feb 2022 11:39:48 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Content-Language: en-US To: Liam Howlett , =?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" , "hughd@google.com" , "kirill@shutemov.name" , "riel@surriel.com" , "rostedt@goodmis.org" , "peterz@infradead.org" References: <20220218122019.130274-1-matenajakub@gmail.com> <20220218122019.130274-5-matenajakub@gmail.com> <20220218195729.oa5olrcsq6yox7hp@revolver> From: Vlastimil Babka Subject: Re: [RFC PATCH 4/4] [PATCH 4/4] mm: add tracing for VMA merges In-Reply-To: <20220218195729.oa5olrcsq6yox7hp@revolver> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.0 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=no 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 2/18/22 20:57, Liam Howlett wrote: >> /* >> * Can we merge both predecessor and successor? >> */ >> - if (merge_prev && merge_next) >> + if (merge_prev >= MERGE_OK && merge_next >= MERGE_OK) { > > What happened to making vma_merge easier to read? What does > MERGE_OK > mean? I guess this answers why booleans were not used, but I don't like It's similar to e.g. enum compact_priority where specific values are defined as well as more abstract aliases. > it. Couldn't you just log the err/success and the value of > merge_prev/merge_next? It's not like the code tries more than one way > of merging on failure.. An initial version had the "log" (trace point really) at multiple places and it was uglier than collecting details in the variables and having a single tracepoint call site. Note that the tracepoint is being provided as part of the series mainly to allow evaluation of the series. If it's deemed too specific to be included in mainline in the end, so be it. >> merge_both = is_mergeable_anon_vma(prev->anon_vma, next->anon_vma, NULL); >> + } >> >> - if (merge_both) { /* cases 1, 6 */ >> + if (merge_both >= MERGE_OK) { /* cases 1, 6 */ >> err = __vma_adjust(prev, prev->vm_start, >> next->vm_end, prev->vm_pgoff, NULL, >> prev); >> area = prev; >> - } else if (merge_prev) { /* cases 2, 5, 7 */ >> + } else if (merge_prev >= MERGE_OK) { /* cases 2, 5, 7 */ >> err = __vma_adjust(prev, prev->vm_start, >> end, prev->vm_pgoff, NULL, prev); >> area = prev; >> - } else if (merge_next) { >> + } else if (merge_next >= MERGE_OK) { >> if (prev && addr < prev->vm_end) /* case 4 */ >> err = __vma_adjust(prev, prev->vm_start, >> addr, prev->vm_pgoff, NULL, next); >> @@ -1252,7 +1255,7 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm, >> } else { >> err = -1; >> } >> - >> + trace_vm_av_merge(err, merge_prev, merge_next, merge_both); >> /* >> * Cannot merge with predecessor or successor or error in __vma_adjust? >> */ >> @@ -3359,6 +3362,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap, >> /* >> * Source vma may have been merged into new_vma >> */ >> + trace_vm_pgoff_merge(vma, anon_pgoff_updated); >> + >> if (unlikely(vma_start >= new_vma->vm_start && >> vma_start < new_vma->vm_end)) { >> /* >> -- >> 2.34.1 >>