From mboxrd@z Thu Jan 1 00:00:00 1970 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,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 8A3DCC433E2 for ; Tue, 23 Mar 2021 10:54:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B7B9619C9 for ; Tue, 23 Mar 2021 10:54:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230295AbhCWKxp (ORCPT ); Tue, 23 Mar 2021 06:53:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229943AbhCWKxb (ORCPT ); Tue, 23 Mar 2021 06:53:31 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B592C061574 for ; Tue, 23 Mar 2021 03:53:29 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id e18so20282557wrt.6 for ; Tue, 23 Mar 2021 03:53:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=WGlnCIX+gPkt5saLRl1AO/eSfyQX4KhnrSrkJYnpgYY=; b=lIV8cb4KFfS7wkzFGd10vbdRrumERBd84XwjQG3DjbGuRdwbmikbg0jk61DgpoawxN BBl7QlKsTaJXnPCOF2y6MKlpThqG96Zmz81Yrp+FEZ6nTCt8av7uCsN5iwc29SpdsQSl EiW8j9VDV469niDRLYcAmzwI0D62kxpgUkue6nlgB7GxWnCpKMJp7zKfYmw4LCttdy0W G+gypPOTuKhWasizmui5cLDWk8ApZ/QXiji5JiDhmE2Nqmn2He3ID9hBKFsjODY4B8Q9 b/M0eeC82xya4hZASNOjs2fKQtd+/3nIbS+1xCePGaJtlOEzWWikRqqdme5aVwM8jGf1 rxZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=WGlnCIX+gPkt5saLRl1AO/eSfyQX4KhnrSrkJYnpgYY=; b=c2rn0oQomYTJekzk/jmg5GfwymDabUTEgm7a+AIlaq308Yw4USQEXkaDIP27e6R38Q KQyJbBXYunJ7nbv1/qy0h5m66BXn51A4V44/Z+TtThQ2WTy1i/46KOgWQSbuAnwM1J/I r5s41JUkaO2nAadZP13xf7kkMiq3zUbW1YJWrykVJoRmikxBZcpUonZxxC6PvQA4sqFx XmdbeTLUvipWX7tD9IskByi+s7ZBhLgT+iYim2DRXgm40iE/RD8pT/azPsaWTJGsASqa 3H47jYyPiRwpqQXVTU5qhy5WTq++Lvk74X/hdTR4hYeYsu63f5EerF/I5wkesvpz9zh+ zVvg== X-Gm-Message-State: AOAM532CoCzPwU2A+thSRPuyNTKbRpZdS6gkIeFuvpIn/79cafhYcv6W rE5mWMYD0YRa/+USLRBdbCEk1A== X-Google-Smtp-Source: ABdhPJxsZ4rfGrv8Gu+78757z6bQt9fLbU/W53+clBFuohI6UOhnceZv0BUdjXF3LdKpnrW2LNNtVA== X-Received: by 2002:a5d:4d01:: with SMTP id z1mr3253375wrt.133.1616496808336; Tue, 23 Mar 2021 03:53:28 -0700 (PDT) Received: from myrica ([2001:1715:4e26:a7e0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id z1sm23063818wru.95.2021.03.23.03.53.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 03:53:27 -0700 (PDT) Date: Tue, 23 Mar 2021 11:53:10 +0100 From: Jean-Philippe Brucker To: "Raj, Ashok" Cc: joro@8bytes.org, will@kernel.org, vivek.gautam@arm.com, guohanjun@huawei.com, zhukeqian1@huawei.com, wangzhou1@hisilicon.com, linux-acpi@vger.kernel.org, zhangfei.gao@linaro.org, lenb@kernel.org, devicetree@vger.kernel.org, kevin.tian@intel.com, jacob.jun.pan@linux.intel.com, eric.auger@redhat.com, vdumpa@nvidia.com, robh+dt@kernel.org, linux-arm-kernel@lists.infradead.org, rjw@rjwysocki.net, shameerali.kolothum.thodi@huawei.com, iommu@lists.linux-foundation.org, sudeep.holla@arm.com, robin.murphy@arm.com, linux-accelerators@lists.ozlabs.org, baolu.lu@linux.intel.com Subject: Re: [PATCH v13 06/10] iommu: Add a page fault handler Message-ID: References: <20210302092644.2553014-1-jean-philippe@linaro.org> <20210302092644.2553014-7-jean-philippe@linaro.org> <20210303055727.GF1914@otc-nc-03> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210303055727.GF1914@otc-nc-03> Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org On Tue, Mar 02, 2021 at 09:57:27PM -0800, Raj, Ashok wrote: > > + ret = handle_mm_fault(vma, prm->addr, fault_flags, NULL); > > Should we add a trace similar to trace_page_fault_user() or kernel in > arch/x86/kernel/mm/fault.c Yes that would definitely be useful for debugging hardware and developping applications. I can send a separate patch to add tracepoints here and in the lower-level device fault path. > or maybe add a perf_sw_event() for device faults? It does seem like that would fit well alongside the existing PERF_COUNT_SW_PAGE_FAULTS, but I don't think it would be useful in practice, because we can't provide a context for the event. Since we're handling these faults remotely, the only way for a user to get IOPF events is to enable them on all CPUs and all tasks. Tracepoints can have 'pasid' and 'device' fields to identify an event, but the perf_sw_event wouldn't have any useful metadata apart from the faulting address. We could also add tracepoints on bind(), so users can get the PASID obtained with the PID they care about and filter fault events based on that. I've been wondering about associating a PASID with a PID internally, because we don't currently have anywhere to send SEGV signals for unhandled page faults. But I think it would be best to notify the device driver on unhandled fault and let them deal with it. They'll probably want that information anyway. Thanks, Jean From mboxrd@z Thu Jan 1 00:00:00 1970 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=-3.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_RED 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 A1BDFC433DB for ; Tue, 23 Mar 2021 10:53:34 +0000 (UTC) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 40065619BD for ; Tue, 23 Mar 2021 10:53:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 40065619BD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id CD71B835F2; Tue, 23 Mar 2021 10:53:33 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3GaOSzVIeKqY; Tue, 23 Mar 2021 10:53:33 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTP id A7F2E827FA; Tue, 23 Mar 2021 10:53:32 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 59F03C000B; Tue, 23 Mar 2021 10:53:32 +0000 (UTC) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 09A59C0001 for ; Tue, 23 Mar 2021 10:53:31 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id E8B1C6081A for ; Tue, 23 Mar 2021 10:53:30 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp3.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=linaro.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XoarBOkdC-V1 for ; Tue, 23 Mar 2021 10:53:30 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by smtp3.osuosl.org (Postfix) with ESMTPS id 036796068A for ; Tue, 23 Mar 2021 10:53:29 +0000 (UTC) Received: by mail-wr1-x430.google.com with SMTP id j7so20291337wrd.1 for ; Tue, 23 Mar 2021 03:53:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=WGlnCIX+gPkt5saLRl1AO/eSfyQX4KhnrSrkJYnpgYY=; b=lIV8cb4KFfS7wkzFGd10vbdRrumERBd84XwjQG3DjbGuRdwbmikbg0jk61DgpoawxN BBl7QlKsTaJXnPCOF2y6MKlpThqG96Zmz81Yrp+FEZ6nTCt8av7uCsN5iwc29SpdsQSl EiW8j9VDV469niDRLYcAmzwI0D62kxpgUkue6nlgB7GxWnCpKMJp7zKfYmw4LCttdy0W G+gypPOTuKhWasizmui5cLDWk8ApZ/QXiji5JiDhmE2Nqmn2He3ID9hBKFsjODY4B8Q9 b/M0eeC82xya4hZASNOjs2fKQtd+/3nIbS+1xCePGaJtlOEzWWikRqqdme5aVwM8jGf1 rxZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=WGlnCIX+gPkt5saLRl1AO/eSfyQX4KhnrSrkJYnpgYY=; b=kbTWEKUc50RvlzS8MzQDatrsA9agFM9qQD6ID6mgMRsO6y0vq7aslfcUhygdWdmKwS nGzNTiachiAFKvVXaroYSXWNjsD5SVw5I5YDesR22E3+SPioxb0jcn4sfi3GtNrcs2rt /z1rq4fWHIczy5IHurJKSV1XCUDIMnkafyx05b8kN5LhJdFdZIV+HbXod3fTyAbPYsD4 p1NwxoNH5+KYDFR1RGVdv1RBZ5Qj1+oei+Cr7sg0N/xc+MdUEAXRskqm1smCFpMKtVFo 60T6PLpXv5b3qqy+mFp2yjKZKODTCFE5MLNsmeDaPY3Q4IKfDnhEONtt2H8nKsuE+TKF fjDw== X-Gm-Message-State: AOAM533U115oenlNG+/shjMu6nvlkk4A/v4hI0/ztgK53L/5Ij2pnS6v deCVeyWSG71cI6wyFkT5cT9j/w== X-Google-Smtp-Source: ABdhPJxsZ4rfGrv8Gu+78757z6bQt9fLbU/W53+clBFuohI6UOhnceZv0BUdjXF3LdKpnrW2LNNtVA== X-Received: by 2002:a5d:4d01:: with SMTP id z1mr3253375wrt.133.1616496808336; Tue, 23 Mar 2021 03:53:28 -0700 (PDT) Received: from myrica ([2001:1715:4e26:a7e0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id z1sm23063818wru.95.2021.03.23.03.53.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 03:53:27 -0700 (PDT) Date: Tue, 23 Mar 2021 11:53:10 +0100 From: Jean-Philippe Brucker To: "Raj, Ashok" Subject: Re: [PATCH v13 06/10] iommu: Add a page fault handler Message-ID: References: <20210302092644.2553014-1-jean-philippe@linaro.org> <20210302092644.2553014-7-jean-philippe@linaro.org> <20210303055727.GF1914@otc-nc-03> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210303055727.GF1914@otc-nc-03> Cc: vivek.gautam@arm.com, guohanjun@huawei.com, will@kernel.org, linux-acpi@vger.kernel.org, zhangfei.gao@linaro.org, lenb@kernel.org, devicetree@vger.kernel.org, kevin.tian@intel.com, robh+dt@kernel.org, linux-arm-kernel@lists.infradead.org, rjw@rjwysocki.net, iommu@lists.linux-foundation.org, sudeep.holla@arm.com, robin.murphy@arm.com, linux-accelerators@lists.ozlabs.org X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" On Tue, Mar 02, 2021 at 09:57:27PM -0800, Raj, Ashok wrote: > > + ret = handle_mm_fault(vma, prm->addr, fault_flags, NULL); > > Should we add a trace similar to trace_page_fault_user() or kernel in > arch/x86/kernel/mm/fault.c Yes that would definitely be useful for debugging hardware and developping applications. I can send a separate patch to add tracepoints here and in the lower-level device fault path. > or maybe add a perf_sw_event() for device faults? It does seem like that would fit well alongside the existing PERF_COUNT_SW_PAGE_FAULTS, but I don't think it would be useful in practice, because we can't provide a context for the event. Since we're handling these faults remotely, the only way for a user to get IOPF events is to enable them on all CPUs and all tasks. Tracepoints can have 'pasid' and 'device' fields to identify an event, but the perf_sw_event wouldn't have any useful metadata apart from the faulting address. We could also add tracepoints on bind(), so users can get the PASID obtained with the PID they care about and filter fault events based on that. I've been wondering about associating a PASID with a PID internally, because we don't currently have anywhere to send SEGV signals for unhandled page faults. But I think it would be best to notify the device driver on unhandled fault and let them deal with it. They'll probably want that information anyway. Thanks, Jean _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu From mboxrd@z Thu Jan 1 00:00:00 1970 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=-4.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 A2A80C433C1 for ; Tue, 23 Mar 2021 10:55:05 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3055C619BA for ; Tue, 23 Mar 2021 10:55:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3055C619BA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=R3Pq6VrGZmj0TETaRhH4d+9NL03o1uFoGr1hPiRm9hg=; b=m9uqzX/Jpg8xRYy6IzrX+zPG7 UePsAwoOzLIcJf2z5Zxo89nh5P+Vksl+M4jO+QeHHc275cefuUl/MEHmXXby0sUsLilZj+uqOU407 YzF8YzKhcTBNL8bqbbtRqVT1BB3/dgzJkYC1WnaUHQXHXHKhPN6ELQKvapMNCjQnZYtBbRswpS18T 5I14tqtm0AHSQ5Iqn1xfo+WbpoNbEHlkkrkDUkv9DNAr8a9doxzwX1n2f04vHGYLyK7HTMzGWbosa ThEhMQvEfVBqHAHW69gLz+cNu/vWRXD3hnYfHMhCvva/IA9NxYiWln9j71uKSHrd6a8NRLy9Aki7i BnPYj8RQA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lOefG-00EfA7-Ag; Tue, 23 Mar 2021 10:53:34 +0000 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lOefA-00Ef9K-Vb for linux-arm-kernel@lists.infradead.org; Tue, 23 Mar 2021 10:53:30 +0000 Received: by mail-wr1-x435.google.com with SMTP id 61so20242995wrm.12 for ; Tue, 23 Mar 2021 03:53:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=WGlnCIX+gPkt5saLRl1AO/eSfyQX4KhnrSrkJYnpgYY=; b=lIV8cb4KFfS7wkzFGd10vbdRrumERBd84XwjQG3DjbGuRdwbmikbg0jk61DgpoawxN BBl7QlKsTaJXnPCOF2y6MKlpThqG96Zmz81Yrp+FEZ6nTCt8av7uCsN5iwc29SpdsQSl EiW8j9VDV469niDRLYcAmzwI0D62kxpgUkue6nlgB7GxWnCpKMJp7zKfYmw4LCttdy0W G+gypPOTuKhWasizmui5cLDWk8ApZ/QXiji5JiDhmE2Nqmn2He3ID9hBKFsjODY4B8Q9 b/M0eeC82xya4hZASNOjs2fKQtd+/3nIbS+1xCePGaJtlOEzWWikRqqdme5aVwM8jGf1 rxZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=WGlnCIX+gPkt5saLRl1AO/eSfyQX4KhnrSrkJYnpgYY=; b=OJ6w/vluDluKsIBkRrlm+hdE3IhSY5iKxyWIbLqzGSwR+6mRc8SE9vO/wKgjvo1AIv 6oWGHprpm58WV/gJoqS6ixjv6f4GMqEHJOd8cK2Ez2hj22auCMTCKiqSiv+4uFFNjaha yUqXPPSwqo3JjipaWfm7qUlryXWeshAs8hNf57NyTGYHXWEhCEPDmAtWdYL+pdsLRfSt gWEHwE0cadMm5HhXdzDr4R3ZTNghnIHQYFJA14Do0rY/GSloMyz+XodBys0WLWjx17th mgHJm2lHHuYr8Xog/ahVn/lNfWlhsiQzkeuPic7MW/UXwPmDuN4uD1mAwGVocJNKvxBm F7Mw== X-Gm-Message-State: AOAM532oNpVVdDE6dYnOzvbOekOfkoqUcnFZj6CZOuhoMc3U/pYqTPTc fLlq42aFozVgRqZomLYrIHr1Rg== X-Google-Smtp-Source: ABdhPJxsZ4rfGrv8Gu+78757z6bQt9fLbU/W53+clBFuohI6UOhnceZv0BUdjXF3LdKpnrW2LNNtVA== X-Received: by 2002:a5d:4d01:: with SMTP id z1mr3253375wrt.133.1616496808336; Tue, 23 Mar 2021 03:53:28 -0700 (PDT) Received: from myrica ([2001:1715:4e26:a7e0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id z1sm23063818wru.95.2021.03.23.03.53.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 03:53:27 -0700 (PDT) Date: Tue, 23 Mar 2021 11:53:10 +0100 From: Jean-Philippe Brucker To: "Raj, Ashok" Subject: Re: [PATCH v13 06/10] iommu: Add a page fault handler Message-ID: References: <20210302092644.2553014-1-jean-philippe@linaro.org> <20210302092644.2553014-7-jean-philippe@linaro.org> <20210303055727.GF1914@otc-nc-03> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210303055727.GF1914@otc-nc-03> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210323_105329_161463_C16BA4F8 X-CRM114-Status: GOOD ( 16.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: vivek.gautam@arm.com, guohanjun@huawei.com, zhukeqian1@huawei.com, will@kernel.org, joro@8bytes.org, wangzhou1@hisilicon.com, linux-acpi@vger.kernel.org, zhangfei.gao@linaro.org, lenb@kernel.org, devicetree@vger.kernel.org, kevin.tian@intel.com, jacob.jun.pan@linux.intel.com, eric.auger@redhat.com, robh+dt@kernel.org, linux-arm-kernel@lists.infradead.org, rjw@rjwysocki.net, shameerali.kolothum.thodi@huawei.com, iommu@lists.linux-foundation.org, sudeep.holla@arm.com, robin.murphy@arm.com, linux-accelerators@lists.ozlabs.org, baolu.lu@linux.intel.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Mar 02, 2021 at 09:57:27PM -0800, Raj, Ashok wrote: > > + ret = handle_mm_fault(vma, prm->addr, fault_flags, NULL); > > Should we add a trace similar to trace_page_fault_user() or kernel in > arch/x86/kernel/mm/fault.c Yes that would definitely be useful for debugging hardware and developping applications. I can send a separate patch to add tracepoints here and in the lower-level device fault path. > or maybe add a perf_sw_event() for device faults? It does seem like that would fit well alongside the existing PERF_COUNT_SW_PAGE_FAULTS, but I don't think it would be useful in practice, because we can't provide a context for the event. Since we're handling these faults remotely, the only way for a user to get IOPF events is to enable them on all CPUs and all tasks. Tracepoints can have 'pasid' and 'device' fields to identify an event, but the perf_sw_event wouldn't have any useful metadata apart from the faulting address. We could also add tracepoints on bind(), so users can get the PASID obtained with the PID they care about and filter fault events based on that. I've been wondering about associating a PASID with a PID internally, because we don't currently have anywhere to send SEGV signals for unhandled page faults. But I think it would be best to notify the device driver on unhandled fault and let them deal with it. They'll probably want that information anyway. Thanks, Jean _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel