Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp828771pxb; Tue, 12 Apr 2022 14:37:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVTSfY9GKLpuYKKQB/L7DNbtzvMeT15XuexcLUU8XmimS9uK7hXwsTuEQ1tte2ZtBMD5ov X-Received: by 2002:a17:902:850b:b0:158:27a2:66eb with SMTP id bj11-20020a170902850b00b0015827a266ebmr22966742plb.5.1649799439798; Tue, 12 Apr 2022 14:37:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649799439; cv=none; d=google.com; s=arc-20160816; b=eq/uSjRmiCO0U6iE4PEycl9Gu6QIL/eL7fgiDPAuUqUo6MAjnrkpvO+D5cAipaseer vo4yFEho64ml6cK2Wk8FMsnt1j1V31w1hH3oLux3Cp/37+ySgqcpnrUj8JwKlxrY4aUv og857er7dJH1OQfTnbGuJV7UUF5/6OMLqsKJHZfANe2gvEs0m/WxYF85829bC5efw5YL JU0y3gVVNUBgqkXxw4x9bq/J5SNiRdya/rAt3ZFrhCdXFe/8YNCwk7b/I/pNcjpYY6yd pAidEjUKyxN3l7aE1fPY5aJaywm+U3YjUBnGk6U/7hEbXYiZntwMqJkDoQLvswUlY4zb 6QHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:from:references:cc:to :subject:message-id:dkim-signature; bh=+Nw/81EzAzg32b0b63hZbzdAlSaSPQJFfPDQ8bOr+dk=; b=se2DHM9GmLvwNvqiBzjCNvH4WnlU8Iwcqq7qIsG/LdB3dIGlZUOttilIkpXbKgBz+p t/uSFbWkUVtr9lRBC8XlmOrOm39+/StFTkFNcdbwji8tNAjTNQebiH3EZO/Ev1q1pIqN EOOTC3C8eRZO38rtFsh6sn/a53SCtt9SQcM0KGgwWO3EJb3AhYxTkh5DQFnp6EL2w2GD 9ayKrUcJeutdQDXf5wqcx6GDOyNead7j5t4LTMsKQbU9b85N/iw1fR2pE8n550istlAG S/kLiG8XjELkmQ3ViTu3COY/G9EwYUHFOVm3FCjPt89LfVUo4AQwjrYdXxIFKytkODT7 NmLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foxmail.com header.s=s201512 header.b=WHDhRlFL; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id rm6-20020a17090b3ec600b001c654567133si18411514pjb.186.2022.04.12.14.37.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 14:37:19 -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=@foxmail.com header.s=s201512 header.b=WHDhRlFL; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 71706BBE36; Tue, 12 Apr 2022 13:41:34 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354785AbiDLIF5 (ORCPT + 99 others); Tue, 12 Apr 2022 04:05:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353785AbiDLHZy (ORCPT ); Tue, 12 Apr 2022 03:25:54 -0400 X-Greylist: delayed 60956 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 12 Apr 2022 00:04:19 PDT Received: from out203-205-251-84.mail.qq.com (unknown [203.205.251.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA2916256 for ; Tue, 12 Apr 2022 00:04:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1649747054; bh=+Nw/81EzAzg32b0b63hZbzdAlSaSPQJFfPDQ8bOr+dk=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=WHDhRlFLuUtf+6qTzyJUKuWWTm6bnZVNTBSWGCX+2v67SVOCTiMyZ29lCUUuzJLKA Aa6dPwx66T/YxtIdPvwmc9CaEr56j1Ep5w2IDuEcmbf5C+yW/iiFdM8woqYRGrQ44X Ck0LZ9SjG7iO7jZcH/Fsc1ay7IvkP3+7RFanF5io= Received: from [IPv6:240e:362:406:cc00:1037:1d58:2ba:46b6] ([240e:362:406:cc00:1037:1d58:2ba:46b6]) by newxmesmtplogicsvrsza5.qq.com (NewEsmtp) with SMTP id 10A1781B; Tue, 12 Apr 2022 15:04:10 +0800 X-QQ-mid: xmsmtpt1649747050t25c06aya Message-ID: X-QQ-XMAILINFO: OZZSS56D9fAjkkO1MRHXn0IzBI/HiOM9PhWrX0Q2YE3pYwi5OJHPJwDADUq060 vN3f2kY/K3AoMyxnFfz+KUdn/3oa1F2UFhhm+Fk217AR30+hGKu58xLK6H1ct8aOp8SwHdqaNbjU Ar2QQCFmrOcGNaNDoo58jF2+jMsJkeOs59nreUY9Jtr9YDeOxMKiHjGeRO3vCSUmGfs0y5TlT1GD f3Exyc0uE9ubv0Eof325Jq7rqD9e4UV+ggOA/3+eD7IoMn2DriA1RbxYNA3nktXX+UUoJG86HqbM qCIrQjLM/VkhR76cuSlwVDML7Pm8sAxsTF2Zy6JzCtzK3nfllO/aStqIdYzOUC7+r4GDJLaGgVl4 X1yBFXzvfZcpmihWgHsm27aeBnW3xlAteQIJoXy+GdBBu4DPbfHKDmwnMuf5+dLbMiToz1+NHFmM FQt0aYat1iIF5WSUL0/A2wI5vsW9/Fy7O7g3SoXvs9/MEk0ALYqCWLv+IkH7ZA//F7ncfxvi7IqW TGNTY1u9M0IHj4rjr5r4By0oVG/8pkou+wnUns4mjdxsUgTFapjVV+QeWshgHh3tl7DKTUZVQtW/ RCfogvyi15C87hQ47jC0jCPb4tQ7xgRmmVgphFSR8DJJhMYuKVRIHdykJMYSpiPckIbQsLA3sjGx piIpA1ivk1K52u1h39hyT3LST29Cf36FpFMc11FZKb7tPDNm3BFkOgBQUKqHeMZ8ZF6ed9oFZuUD HhtR1HEFR0mxZjOffYQzvC6xgPvNIpH6RxbSzXyFrJo9vJHKYQZUAKhOYPNesLOzu5OPho5V1aAR n8J0UuhisSqvlq6FKL3IHNLsB3s6ny/r8IcjLHF8/vieoWFV7AZYAH9GRmYvBEpgSp+ILrI/xzk8 nhYwrHHpUyI1EFlXZHDx+VCHHdSUGUiBhbvqJ2/3DmxqNKyxvxog3W1TDrnqT9rVJILKA2RTAdnq WPz1Q2HZc= Subject: Re: [PATCH v4 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit To: Dave Hansen , Joerg Roedel , Fenghua Yu , jean-philippe Cc: Ravi V Shankar , Tony Luck , Ashok Raj , Peter Zijlstra , Dave Hansen , x86 , linux-kernel , iommu , Ingo Molnar , Borislav Petkov , Andy Lutomirski , Josh Poimboeuf , Thomas Gleixner References: <20220207230254.3342514-1-fenghua.yu@intel.com> <20220207230254.3342514-6-fenghua.yu@intel.com> <56ed509d-a7cf-1fde-676c-a28eb204989b@intel.com> From: "zhangfei.gao@foxmail.com" X-OQ-MSGID: Date: Tue, 12 Apr 2022 15:04:09 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FORGED_MUA_MOZILLA,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,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 2022/4/11 下午10:52, Dave Hansen wrote: > On 4/11/22 07:44, zhangfei.gao@foxmail.com wrote: >> On 2022/4/11 下午10:36, Dave Hansen wrote: >>> On 4/11/22 07:20, zhangfei.gao@foxmail.com wrote: >>>>> Is there nothing before this call trace?  Usually there will be at least >>>>> some warning text. >>>> I added dump_stack() in ioasid_free. >>> Hold on a sec, though... >>> >>> What's the *problem* here?  Did something break or are you just saying >>> that something looks weird to _you_? >> After this, nginx is not working at all, and hardware reports error. >> Suppose the the master use the ioasid for init, but got freed. >> >> hardware reports: >> [  152.731869] hisi_sec2 0000:76:00.0: qm_acc_do_task_timeout [error status=0x20] found >> [  152.739657] hisi_sec2 0000:76:00.0: qm_acc_wb_not_ready_timeout [error status=0x40] found >> [  152.747877] hisi_sec2 0000:76:00.0: sec_fsm_hbeat_rint [error status=0x20] found >> [  152.755340] hisi_sec2 0000:76:00.0: Controller resetting... >> [  152.762044] hisi_sec2 0000:76:00.0: QM mailbox operation timeout! >> [  152.768198] hisi_sec2 0000:76:00.0: Failed to dump sqc! >> [  152.773490] hisi_sec2 0000:76:00.0: Failed to drain out data for stopping! >> [  152.781426] hisi_sec2 0000:76:00.0: QM mailbox is busy to start! >> [  152.787468] hisi_sec2 0000:76:00.0: Failed to dump sqc! >> [  152.792753] hisi_sec2 0000:76:00.0: Failed to drain out data for stopping! >> [  152.800685] hisi_sec2 0000:76:00.0: QM mailbox is busy to start! >> [  152.806730] hisi_sec2 0000:76:00.0: Failed to dump sqc! >> [  152.812017] hisi_sec2 0000:76:00.0: Failed to drain out data for stopping! >> [  152.819946] hisi_sec2 0000:76:00.0: QM mailbox is busy to start! >> [  152.825992] hisi_sec2 0000:76:00.0: Failed to dump sqc! > That would have been awfully handy information to have in an initial bug report. :) > Is there a chance you could dump out that ioasid alloc *and* free information in ioasid_alloc/free()? This could be some kind of problem with the allocator, or with copying the ioasid at fork. The issue is nginx master process init resource, start daemon process, then master process quit and free ioasid. The daemon nginx process is not the original master process. master process:  init resource driver -> iommu_sva_bind_device -> ioasid_alloc nginx : ngx_daemon fork daemon, without add mm's refcount. src/os/unix/ngx_daemon.c ngx_daemon(ngx_log_t *log) {     int  fd;     switch (fork()) {     case -1:         ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, "fork() failed");         return NGX_ERROR;     case 0:        // here master process is quit directly and will be released.         break;     default:         exit(0);     } // here daemon process take control.     ngx_parent = ngx_pid;     ngx_pid = ngx_getpid(); fork.c copy_mm         if (clone_flags & CLONE_VM) {                 mmget(oldmm);                 mm = oldmm;         } else {                 mm = dup_mm(tsk, current->mm);    // here daemon process handling without mmget. master process quit, mmput ->  mm_pasid_drop->ioasid_free But this ignore driver's iommu_sva_unbind_device function, iommu_sva_bind_device and iommu_sva_unbind_device are not pair,  So driver does not know ioasid is freed. Any suggestion? Or can we still use the original ioasid refcount mechanism? Thanks