Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2541750lqt; Mon, 22 Apr 2024 13:53:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXUfIUZYNlxW56eDVZugHPaOIMMZhL5Osg77TRpUY6JeRgS+68sTbM4N10mn3ySkBRK6Pfe+mVl3guZh9J46FeiwP2UOOrocZ9DrdSOKg== X-Google-Smtp-Source: AGHT+IFJdVm75b5WFHpcF2u5F9KkjMQmHx/30bYOideX8iDHY+ANgXibSl9RJa7lOwgLEL8ZWRvN X-Received: by 2002:a17:90a:5804:b0:2a2:3252:cb83 with SMTP id h4-20020a17090a580400b002a23252cb83mr10730372pji.38.1713819217548; Mon, 22 Apr 2024 13:53:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713819217; cv=pass; d=google.com; s=arc-20160816; b=e5A2Y45aeUzS0oYnsam5GsHURmJ5K1eerRmW1MwxxpoZK68MPah8NmEpXVgFvVoiVZ ZR98tpSEKnss5yg36YZSGHX+tM2y9US8UPMRnIr92seXxh+4CWFmghwDG+OXzQ+L/EeU xT3AGZVy7lDlp2uFZ6RgT7/agWNliN/y+qD54O69089VkysKCOEbijaAAMbgupa2t2CB 9/5vxWZ+UmGhSqqdXJIj4sxFYqkgpGTH5V6uKC55l6g8UPWlrkHe+ycBjXSGwqXSfm+N 56DBom4W6fY9d1JbDWDng97lwUxFTZhNGUTp/9rb128IiIwbwiN14vcJorrNpTRfl7lE Ncew== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=SS0hZxf5Um6ckcjPrS2C6yFU/ft2AfTBLo5VA71mThw=; fh=Iwy4q+VZTcRTgeQ8s0F9Bu+hpnJc8n0pwmMDOkEdtfo=; b=lcvGPclMJghMMQQHxn1Dy8z0rVnVRTRV4PP/dh8WFfWDifpHv4DqizRZ34jwskjtYe nHWfe8XOd84yrIaGXBp5T8VOfSD5Q8dbuyHMtRAoxtMHgbtEx3Rz2O3bCM2+hI5S2vjU fCVjHnzjXRYKheGrHoYayPrg4Qwj8lxTcSlMchDDUrHO7R+AjqG7LLZXcT7bclpa3whS O3+KIEiY6exqg5yRuWbMSYEUbsav4IyqpkSCmmsBUNm/2WUcwrZOVnjZy19IMgcryDMT 4+bcz3u5BDLBawMIRX6zLv2lcLO2ZaCNGeNZ/LnDu2ZkAxySEQ7d0PBB3stIRMciLeEi 9YUA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@morinfr.org header.s=20170427 header.b="N+d/66ae"; arc=pass (i=1 spf=pass spfdomain=morinfr.org dkim=pass dkdomain=morinfr.org dmarc=pass fromdomain=morinfr.org); spf=pass (google.com: domain of linux-kernel+bounces-154017-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154017-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=morinfr.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id oc9-20020a17090b1c0900b002ae6a9d4f48si783754pjb.124.2024.04.22.13.53.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 13:53:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-154017-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=fail header.i=@morinfr.org header.s=20170427 header.b="N+d/66ae"; arc=pass (i=1 spf=pass spfdomain=morinfr.org dkim=pass dkdomain=morinfr.org dmarc=pass fromdomain=morinfr.org); spf=pass (google.com: domain of linux-kernel+bounces-154017-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154017-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=morinfr.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 240AB283585 for ; Mon, 22 Apr 2024 20:53:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 59CF31BDC4; Mon, 22 Apr 2024 20:53:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=morinfr.org header.i=@morinfr.org header.b="N+d/66ae" Received: from smtp2-g21.free.fr (smtp2-g21.free.fr [212.27.42.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E58ADDC3; Mon, 22 Apr 2024 20:53:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.27.42.2 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713819211; cv=none; b=F5f/mNi7DjRS18kx2GHQ2EFocgWU12SdAsEbSnuCuHGWSjI/aP5lpDlAXB/12P3zoM857Lio4gtVZAGJkNjGUVEMHO8F2GTBQ0wZnLLKIfnPcTpqetFvM4JnaAZabqrjJkHGfN5TReDN5oVVh0NCMBHA3Vzi3AaxBodqvkq748g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713819211; c=relaxed/simple; bh=91uZ1D+g7BCvXY8LmzC1Kc3GezTGlSGp7H9DFv37wcQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=CtzXTHEU1j1gjR2W425RvL/csXai8kLMMCYx/UHHcE5K6SRzYTkBkIF7hg43rie3Bi+b4j/kezRQG6+MNjGfIl9RdxJqnPYoTBIocSowHc6zCEPsE6TFrGkVuDWdLB1C81DBvjxGIvTmAm3WyPQqbP5nfhbdxP0wku43RHOYJY4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=morinfr.org; spf=pass smtp.mailfrom=morinfr.org; dkim=pass (1024-bit key) header.d=morinfr.org header.i=@morinfr.org header.b=N+d/66ae; arc=none smtp.client-ip=212.27.42.2 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=morinfr.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=morinfr.org Received: from bender.morinfr.org (unknown [82.66.66.112]) by smtp2-g21.free.fr (Postfix) with ESMTPS id 3DDE82003A4; Mon, 22 Apr 2024 22:53:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=morinfr.org ; s=20170427; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=SS0hZxf5Um6ckcjPrS2C6yFU/ft2AfTBLo5VA71mThw=; b=N+d/66aekExkDZY/KH+e/HXbLK xdKA1kCIwK78ELym0Pzz2xWS0Ip+yXOK47b876sqBklYWuRr71YHSlKdvetT2SGymNyRrTYiGsPF3 0SV4OyU1cW9rm5Kes07NEW4qGRulOnNi1oEZ62YGjdlu0HYuccYfiHJSoclq4ChHjJyQ=; Received: from guillaum by bender.morinfr.org with local (Exim 4.96) (envelope-from ) id 1rz0fA-005AgS-1q; Mon, 22 Apr 2024 22:53:20 +0200 Date: Mon, 22 Apr 2024 22:53:20 +0200 From: Guillaume Morin To: David Hildenbrand Cc: Guillaume Morin , oleg@redhat.com, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, muchun.song@linux.dev Subject: Re: [RFC][PATCH] uprobe: support for private hugetlb mappings Message-ID: References: <22fcde31-16c4-42d0-ad99-568173ec4dd0@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <22fcde31-16c4-42d0-ad99-568173ec4dd0@redhat.com> On 22 Apr 20:59, David Hildenbrand wrote: > > The benefit - to me - is very clear. People do use hugetlb mappings to > > run code in production environments. The perf benefits are there for some > > workloads. Intel has published a whitepaper about it etc. > > Uprobes are a very good tool to do live tracing. If you can restart the > > process and reproduce, you should be able to disable hugetlb remapping > > but if you need to look at a live process, there are not many options. > > Not being able to use uprobes is crippling. > > Please add all that as motivation to the patch description or cover letter. > > > > Yes, libhugetlbfs exists. But why do we have to support uprobes with it? > > > Nobody cared until now, why care now? > > > > I think you could ask the same question for every new feature patch :) > > I have to, because it usually indicates a lack of motivation in the > cover-letter/patch description :P My cover letter was indeed lacking. I will make sure to add this kind of details next time. > > Since the removal a few releases ago of the __morecore() hook in glibc, > > the main feature of libhugetlbfs is ELF segments remapping. I think > > there are definitely a lot of users that simply deal with this > > unnecessary limitation. > > > > I am certainly not shoving this patch through anyone's throat if there > > is no interest. But we definitely find it a very useful feature ... > > Let me try to see if we can get this done cleaner. > > One ugly part (in general here) is the custom page replacement in the > registration part. > > We are guaranteed to have a MAP_PRIVATE mapping. Instead of replacing pages > ourselves (which we likely shouldn't do ...) ... maybe we could use > FAULT_FLAG_UNSHARE faults such that we will get an anonymous folio > populated. (like KSM does nowadays) > > Punching FOLL_PIN|FOLL_LONGTERM into GUP would achieve the same thing, but > using FOLL_WRITE would not work on many file systems. So maybe we have to > trigger an unsharing fault ourselves. > > That would do the page replacement for us and we "should" be able to lookup > an anonymous folio that we can then just modify, like ptrace would. > > But then, there is also unregistration part, with weird conditional page > replacement. Zapping the anon page if the content matches the content of the > original page is one thing. But why are we placing an existing anonymous > page by a new anonymous page when the content from the original page differs > (but matches the one from the just copied page?)? > > I'll have to further think about that one. It's all a bit nasty. Sounds good to me. I am willing to help with the code when you have a plan or testing as you see fit. Let me know. > One thing to note is that hugetlb folios don't grow on trees. Likely, Many > setups *don't* reserve extra hugetlb folios and you might just easily be > running out of free hugetlb folios that you can use to break COW here > (replace a file hugetlb by a fresh anon hugetlb page). Likely it's easy to > make register or unregister fail. Agreed. -- Guillaume Morin