Received: by 10.223.185.116 with SMTP id b49csp2491555wrg; Mon, 5 Mar 2018 03:58:49 -0800 (PST) X-Google-Smtp-Source: AG47ELu1zf4cLrKd5J5tyAveFjXnRpwKqojMrXcGXKBcsK+o45vnLu321Hc4N7FyAADeKkdQH6sL X-Received: by 2002:a17:902:8b85:: with SMTP id ay5-v6mr13150086plb.329.1520251129584; Mon, 05 Mar 2018 03:58:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520251129; cv=none; d=google.com; s=arc-20160816; b=Wv69kHbg8PkclP1gAcWefsPX3oksNkdszsRG/mSKQ6o1k8bT7oDsNFldfsO4TARZW8 kbuGc5Co+h7wz2KaQNcFSbr6cLMT1kqpE2aD0VVpMD5UuqY+hH+5mIc0+5Wt3yDwnVxP 4E9VWLu863uxq/qsHuuTukpS5ZBTey1hTcVMUgNFVj37+Rp9C/6ErDUufFhDWcUhH2A/ bjyl/TuoA5IE9RmvTd/eDCzGgebS41kViWWydHj2TMl1fzBsDsZvQg5g+GSdn7A0uOq8 t39YWCprww87TpqmQYbYRaeaO5D2bolRV41Hm2p1PXvmPc6K7deNQCxhj6d8FYuGZ18y DdxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :to:subject:dkim-signature:arc-authentication-results; bh=LP+hohOahk3bxXdYBBaTBPWgYCARVqXDyWAibiPwjqs=; b=WYW8NUa4awO3bKuX6B6h0jX+uHbb+t75eWxVS7FRstXUWnddEB+FwiYmbI1wWlSJxA OjkhYUUZEfB5UW6ysl1hTVUS+JT/uVhUn10Wa6vEwbx/G93Kq/6GxIJJa72npxvr+iJi O5GNa7GkBES6MSLgl5IimHuZq8X/PXmDkhj69+/Bh5BD+EVTdxfVaN+76rX3s0xonQac R1NQUlqkQaPq4fbK+eMIS6yMlyoBZ9KJqcEmrsN1lL9nqpejc3rhmbPsYf60Bw8grq/o BHJJQlJHzaN0PWGxlOiHlw020VNOq7PCusXs/qyKgM5APA6MprRWSl9MbYNBdsPPLDb7 MBhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=3KvP+v8x; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t17-v6si9024866plo.535.2018.03.05.03.58.35; Mon, 05 Mar 2018 03:58:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=3KvP+v8x; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934564AbeCEL2s (ORCPT + 99 others); Mon, 5 Mar 2018 06:28:48 -0500 Received: from mail-by2nam01on0050.outbound.protection.outlook.com ([104.47.34.50]:63873 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934548AbeCEL2q (ORCPT ); Mon, 5 Mar 2018 06:28:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=LP+hohOahk3bxXdYBBaTBPWgYCARVqXDyWAibiPwjqs=; b=3KvP+v8xQu+273D9a0p79dfCFGgxO3/Ivehs0S6AoNODlN5VKCE0iZCSI0ScQykK3PttkVWVkN7N8NkAvmgCC/4lw14RiPJyMi5qSJH0CbXsff1P0T/+JN39Hld8ybBuH0+yLyRDLKcu92qprZWHprK7u+E84oDSBi2QV5P7C0Q= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Christian.Koenig@amd.com; Received: from [IPv6:2a02:908:1251:8fc0:4c6d:7233:b7e1:3b88] (2a02:908:1251:8fc0:4c6d:7233:b7e1:3b88) by CY4PR12MB1301.namprd12.prod.outlook.com (2603:10b6:903:40::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.548.13; Mon, 5 Mar 2018 11:28:43 +0000 Subject: Re: [PATCH] dma-buf/reservation: shouldn't kfree staged when slot available To: "Liu, Monk" , "dri-devel@lists.freedesktop.org" , "linux-kernel@vger.kernel.org" References: <1519800242-2442-1-git-send-email-Monk.Liu@amd.com> From: =?UTF-8?Q?Christian_K=c3=b6nig?= Message-ID: <210b7a03-f309-8ab6-0f23-17377660e664@amd.com> Date: Mon, 5 Mar 2018 12:28:31 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.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-Originating-IP: [2a02:908:1251:8fc0:4c6d:7233:b7e1:3b88] X-ClientProxiedBy: VI1PR0102CA0021.eurprd01.prod.exchangelabs.com (2603:10a6:802::34) To CY4PR12MB1301.namprd12.prod.outlook.com (2603:10b6:903:40::10) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: d96c9e11-808a-46c2-e5c9-08d5828c4172 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603307)(7153060)(7193020);SRVR:CY4PR12MB1301; X-Microsoft-Exchange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g6KYw/inAJRGzB9aQqiFw7Wzuo4Hvn2YjfELDYKohst34QqBHblic0P6Dmf4xWNcuMVvUhoz0lz3/7gHobPX1icOArct67p8eEeqoMokoMXsoO62p0ePoA88eAnnAuDZkXA/gjalwV/VTQTFnT3exSpp44iFBzWsu7iR8Hscp2dOFgFXziEBwFYW9jI+MdRAtlGgL2POd+LAYElFjxGGWdp7I5Gli8EvBLK3F6g+CaEEuqSKxaKqZ3byrREJ4nviH7FlGQNdtYhfviNxQxxtFcWSjQWK0kJ+kMEZ4Z0iUCgsRKZMOZcS3ErEeWPbU5ncDCET9uYADCKoEta3JiM1JCv3ug7dZHx9Z5nGz6cUWajrwYKS5AS X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055)(85827821059158)(767451399110)(217544274631240)(17755550239193); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040501)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3231220)(944501244)(52105095)(3002001)(6055026)(6041288)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(6072148)(201708071742011);SRVR:CY4PR12MB1301;BCL:0;PCL:0;RULEID:;SRVR:CY4PR12MB1301; X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1301;4:BLFf5d/vAgBDvd+3wuQDwwarp/dxIQjUAs+m7Sa1FMeksOBfYHGcs/okceEjSixmBvh5ozkT9tc5hxx8+Yf0aT8eKqAM1qI0ze7EePPycmxschhJPtPbiM6iXBelXmSAOYqFFnlZYNC+zwh7i/YDH/ldY6TKZYBr7HGPmInzKz/uXytG58CJXDa1iehbGlxTpJqKk0Im6O3UCR4N+EvdsdS9MMQfB43yoHKFWQYd0CvhPAQVPBfM3qQjeg9nzT/ZmsivhVy02XCaiRn1QW+qKM9fALQhivK9gQV3dudMqiBldA5FNwpLALeobYSbnWm6mrYeJ3RsJXeQBVIwoKjTA1fhod8rKKXdMKVJrjnzCgadT3mYRfuky2XsGa39trsli+eZN8XHn8D8/HOMmJB2YJ+8BjRYGljiR9HsMai4FWiE3nO5kD4n5hE0XjaOVqwH X-Forefront-PRVS: 06022AA85F X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(979002)(366004)(396003)(39860400002)(39380400002)(376002)(346002)(189003)(199004)(13464003)(86362001)(31696002)(6246003)(36756003)(6116002)(1706002)(65956001)(53936002)(65806001)(67846002)(2201001)(25786009)(6486002)(6306002)(72206003)(2906002)(76176011)(2486003)(52146003)(52396003)(46003)(23676004)(52116002)(478600001)(2501003)(2870700001)(966005)(105586002)(93886005)(50466002)(58126008)(47776003)(5660300001)(110136005)(16526019)(81166006)(8676002)(186003)(8936002)(81156014)(316002)(65826007)(68736007)(106356001)(305945005)(64126003)(59450400001)(6666003)(7736002)(229853002)(97736004)(2950100002)(53546011)(386003)(31686004)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR12MB1301;H:[IPv6:2a02:908:1251:8fc0:4c6d:7233:b7e1:3b88];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTRQUjEyTUIxMzAxOzIzOk9Eak9ESmxrZHUydlhPY0R6QmhncytoTldx?= =?utf-8?B?bkJZUjJtbFIvV0RWQXV1ZXJOb2RQU1ZuYnlEWndRaG9UR0J2a2RMZjZHaW9F?= =?utf-8?B?QmI1c1VkZk4wQmYyRHJHenpvdzBhQXRaSmxqbExiQ2JHbTVLSTAxampmY01z?= =?utf-8?B?bzVzd2lWK2tEQzNMOVFpRFdnZzN3cU04eEJCR2ZVbmw0S3J3RDBobmVuUWZl?= =?utf-8?B?NUVxRTJmWUM2QTJIQ2NkWHpvenNneE5pMEl3MmhzTUYwNXVqak15cURlc1BS?= =?utf-8?B?aEFEbW5wQmFS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NtBCQbQf5oVha1PgpFpDI9f/ePLSj8bLLgeLxuQrq35E6tRvgQrOVEpdXuBDLYoNYO2ZM6JQ4m33gkZ7uzUkk8NAHcjainiDcSBX3TztFBk6PB SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1301;20:LSN4c5s+OiLoglt+4fT6pUpTPxmPXNi3+QGuZfBmdc06Em57pQgxFyiDPs31gpFKLKR4p1HoT99taxGyKd5pOnxfm+GNE1uPsjzQnHKD5F2B1yYvgGx63naVZvwnTa2xoIUJZUZ/Ey7kcfTmzwowQAv9C6UWTm2QcS4UgGMtweu9eG+Y7CllKbxbseMhrIad2Q6/vdI5KgE/X/uomX693wEBaUCIlkLGFn3tFlHRMUweMSKUCXwwwTGL88cXu/Mf X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2018 11:28:43.9107 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d96c9e11-808a-46c2-e5c9-08d5828c4172 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1301 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 05.03.2018 um 12:25 schrieb Liu, Monk: > And by the way, I add "if (staged!=NULL) BUG();" prior to "kfree(obj->staged)" in reserve_shared() routine, and this BUG() is actually hit, > The stack dump shows it is hit during the vm_bo_update() in gem_va_update()... That is expected. The staged handling just makes sure that there is room available, it doesn't guarantee that it is actually used. E.g. we can end up reserving a fence slot, but then find that we actually don't need it. Christian. > > Besides, the whole reservation logic still looks a little weired to me ... especially this staged part ... > > Thanks > > /Monk > > -----Original Message----- > From: Christian König [mailto:ckoenig.leichtzumerken@gmail.com] > Sent: 2018年3月5日 19:22 > To: Liu, Monk ; Koenig, Christian ; dri-devel@lists.freedesktop.org; linux-kernel@vger.kernel.org > Subject: Re: [PATCH] dma-buf/reservation: shouldn't kfree staged when slot available > > Am 05.03.2018 um 08:55 schrieb Liu, Monk: >> Hi Christian >> >> You are right on that part of obj-staged is set to NULL in add_fence, >> So my following question will be why we kfree(obj->staged) in reserve_shared() if staged is always NULL in that point ? > Good question, I haven't wrote code that so I can't fully answer. > > Maybe Chris or Maarten know more about that. > > Christian. > >> Thanks >> /Monk >> >> -----Original Message----- >> From: Christian König [mailto:ckoenig.leichtzumerken@gmail.com] >> Sent: 2018年2月28日 16:27 >> To: Liu, Monk ; dri-devel@lists.freedesktop.org; >> linux-kernel@vger.kernel.org >> Subject: Re: [PATCH] dma-buf/reservation: shouldn't kfree staged when >> slot available >> >> Am 28.02.2018 um 07:44 schrieb Monk Liu: >>> under below scenario the obj->fence would refer to a wild pointer: >>> >>> 1,call reservation_object_reserved_shared >>> 2,call reservation_object_add_shared_fence >>> 3,call reservation_object_reserved_shared >>> 4,call reservation_object_add_shared_fence >>> >>> in step 1, staged is allocated, >>> >>> in step 2, code path will go reservation_object_add_shared_replace() >>> and obj->fence would be assigned as staged (through RCU_INIT_POINTER) >>> >>> in step 3, obj->staged will be freed(by simple kfree), which make >>> obj->fence point to a wild pointer... >> Well that explanation is still nonsense. See >> reservation_object_add_shared_fence: >>>         obj->staged = NULL; >> Among the first things reservation_object_add_shared_fence() does is >> it sets obj->staged to NULL. >> >> So step 3 will not free anything and we never have a wild pointer. >> >> Regards, >> Christian. >> >>> in step 4, code path will go reservation_object_add_shared_inplace() >>> and inside it the @fobj (which equals to @obj->staged, set by above >>> steps) is already a wild pointer >>> >>> should remov the kfree on staged in >>> reservation_object_reserve_shared() >>> >>> Change-Id: If7c01f1b4be3d3d8a81efa90216841f79ab1fc1c >>> Signed-off-by: Monk Liu >>> --- >>> drivers/dma-buf/reservation.c | 7 ++----- >>> 1 file changed, 2 insertions(+), 5 deletions(-) >>> >>> diff --git a/drivers/dma-buf/reservation.c >>> b/drivers/dma-buf/reservation.c index 375de41..b473ccc 100644 >>> --- a/drivers/dma-buf/reservation.c >>> +++ b/drivers/dma-buf/reservation.c >>> @@ -74,12 +74,9 @@ int reservation_object_reserve_shared(struct reservation_object *obj) >>> old = reservation_object_get_list(obj); >>> >>> if (old && old->shared_max) { >>> - if (old->shared_count < old->shared_max) { >>> - /* perform an in-place update */ >>> - kfree(obj->staged); >>> - obj->staged = NULL; >>> + if (old->shared_count < old->shared_max) >>> return 0; >>> - } else >>> + else >>> max = old->shared_max * 2; >>> } else >>> max = 4; >> _______________________________________________ >> dri-devel mailing list >> dri-devel@lists.freedesktop.org >> https://lists.freedesktop.org/mailman/listinfo/dri-devel