Received: by 10.192.165.156 with SMTP id m28csp487707imm; Fri, 13 Apr 2018 02:42:09 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+7/+j9QPTJTKkTGVC7db0zQRTEFDtcgyp2WFOQv62D435xyX1cCU//G5cV6oQuXs23Htwf X-Received: by 10.101.77.67 with SMTP id j3mr3635032pgt.210.1523612529732; Fri, 13 Apr 2018 02:42:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523612529; cv=none; d=google.com; s=arc-20160816; b=BMXknYLlpN8+QG1kfnitYgBXgVmFRytE/DF0BLGoP10bNL/nQLV0p2ZhE/nB22Ib5t e89AJleezgBPOmii4Ogc2aD16T8v5SDfXzMYNa2H/NQgdRVs1zovk1rQCF5VhXIqD8IV qrPDQTR7Z/Vl35XjThs85l4hIH3qsVlr7qd9ENL3QQubN5rACvDTU2phJJU2QUzJxpuB O01sN7z4djRwc0rHW16uTkIsT8D4d+QGTJsyeMO81vCGeO8pvrIrU9g9pvr/1WU13mms iVSKGNDjVI2s/NZTpsdJPSh8SNBwMVQCdGoV2Ha9/6uBoEKJLdOww2GYdzXhzWSTUcmw R9ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dmarc-filter :dkim-signature:dkim-signature:arc-authentication-results; bh=qRO+r2bTw5nL8yrRJJVY6HaVIaD8SbAH04v1s4fT/RI=; b=tqzIz4x/MOUZSrOgFgrkc7SBdu8TAIiKWTZCmtxBgxDKkoSxykbPa9ReBBc1xSgazp 8Hf1PM03yamh6jSSSs84/G2BI9NOsGpcIuEJNcq0U4z9/1Ik2lZIPPH+PdecvGBfyJMK EjCuYEoBJeXK8xhwMEQN8jNfb7zY3PcOEwSshfWRUKcpwjVjVVuAfRioLMKPxQxVSntn neuuSkPvs2MNrMNmu7Krp25iafh+DHpEoxO3MZFtqUuDjMGuNRXFv7EcyblsUc/KnGsz moCQGdW7xNKq9BdFdP8Qz8PYM0mstScpjPSuI6W31bpzo6JzUwHqvKDUO8KS0cPk4FfJ Uz8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=JNNku3Qx; dkim=pass header.i=@codeaurora.org header.s=default header.b=RYMKhy8I; 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 k9-v6si5113150plt.413.2018.04.13.02.41.55; Fri, 13 Apr 2018 02:42:09 -0700 (PDT) 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=@codeaurora.org header.s=default header.b=JNNku3Qx; dkim=pass header.i=@codeaurora.org header.s=default header.b=RYMKhy8I; 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 S1754029AbeDMIrB (ORCPT + 99 others); Fri, 13 Apr 2018 04:47:01 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:41388 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754001AbeDMIqy (ORCPT ); Fri, 13 Apr 2018 04:46:54 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 62EE96072E; Fri, 13 Apr 2018 08:46:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1523609213; bh=kgPjG5jzJFkLnVwubXP/UKKvOGkWNzD/hNe8GIwlcjs=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=JNNku3QxuztVQxaQvKrdx77h+4HyN+Tw7vG5qlzkhB0CvLREnmF2G36ZR6AtgYvev vTJk3VRbGEjGJKTcQqzD/Y7Mo5HqdZ+k/pDj+Wg//J/b3GamrgyPJEaBJCX2x49xfq YebfxsXLlmQF8v9E4kbsPDAyn/epSfNWdddJg6mY= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from [10.204.78.252] (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: gkohli@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 397F96076C; Fri, 13 Apr 2018 08:46:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1523609212; bh=kgPjG5jzJFkLnVwubXP/UKKvOGkWNzD/hNe8GIwlcjs=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=RYMKhy8IwzD5J+JujToHrSnviCGOilGtBF+fESub5IbfrRDFifFC7xOs+fGgGFPAm /DNURqpEnxBUpJka/tVDm2MQz4Loxao9prdsRW+F7e/2HcDj9OSn2FLg/e6I10Pww5 UpvClmXDa+uFjUXFOy4u9pV9UxKtL0ZXv1KXuxFg= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 397F96076C Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=gkohli@codeaurora.org Subject: Re: Query:Regarding percpu_counter debug object destroy To: Nikolay Borisov , tj@kernel.org, akpm@linux-foundation.org, linux-kernel@vger.kernel.org Cc: linux-arm-msm@vger.kernel.org References: <0754201b-2051-3f1c-7a09-ed1be96a0260@codeaurora.org> From: "Kohli, Gaurav" Message-ID: <219c8a35-49ac-1dbf-7816-95be0be46a1a@codeaurora.org> Date: Fri, 13 Apr 2018 14:16:48 +0530 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Nikolay, Thanks for the comment. I agree ,like timer , hrtimer we have to mark inactive in destroy function and finally freeing the debug object after destruction of percpu_counter. But i am still not sure that this double freeing with same address may create race or not in debug_object list. Regards Gaurav On 4/13/2018 1:12 PM, Nikolay Borisov wrote: > > On 13.04.2018 10:32, Kohli, Gaurav wrote: >> Hi , >> >> I have checked below code and it seems we are calling debug_object_free >> twice, ideally we should deactivate and later we >> have to destroy. >> >> 1st call -> percpu_counter_destroy->debug_percpu_counter_deactivate -> >> debug_object_free >> 2nd call -> >> debug_object_free >> >> >> >> static bool percpu_counter_fixup_free(void *addr, enum debug_obj_state >> state) >> { >>         struct percpu_counter *fbc = addr; >> >>         switch (state) { >>         case ODEBUG_STATE_ACTIVE: >>                 percpu_counter_destroy(fbc);  -> first call >>                 debug_object_free(fbc, &percpu_counter_debug_descr); 2nd > > Having looked at the code I'd say this is indeed buggy. I'd say it > stemmed from same cargo culting since timer_fixup_free follows the same > structure of code, except that in del_timer_sync there is no code which > does debug_object_free. The situation is similar in work_fixup_free. > > So at this point I guess the question is whether we want to leave the > debug_object_free call in percpu_counter_fixup_free and just remove > debug_percpu_counter_deactivate and open-code the call to > debug_object_deactivate in percpu_counter_destroy. Or remove the > explicit call in percpu_counter_fixup_free and leave > debug_percpu_counter_deactivate. > > > In the end it's a matter of style, so perhaps Tejun, as the maintainer, > has the final say what style he prefers. Personally, I'd go for the > former solution so that the percpu follows the style of the rest of the > kernel. > >> call >>                 return true; >>         default: >>                 return false; >>         } >> } >> >> >> We are seeing one issue, where one list contain garbage data in >> obj_hash, just before element of that is percpu_counter but >> still not sure as it is very difficult to reproduce. >> >> Can some one please review above code or can we remove one instance of >> debug_object_free from above code. >> >> Regards >> Gaurav >> >> -- Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.