From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 9BA1A7E9 for ; Thu, 4 Jul 2024 13:17:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720099063; cv=none; b=rkn/h48MOe4sjNo4VXHWV2W0EWL4ddKE8Ea/zNUqo04+jooMk0tnvT8DtA+W6ssV0zriv90yx/NP1qFZoueffMfUcECf/dXMAGta88LVN+8/G1pL1W1QutX1ob+geDNbiGy9jhI6Qwv7/9zUq5lC5KqnjP2vEnv2JPLll7AkDhw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720099063; c=relaxed/simple; bh=zN8afczbWowcWqSfHH5eXrpVHB1LCr8GkbvzG7sUnwY=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=lCaWiK+B899TwsbaQ7lm7gepul6CkqP1AD4Unllq7O3U+BqIpI7bAwQUtSPl8oB40NKAM4j+MTKnAyM3yqpAdsJsr9iiR0hFkRREtVoAHzXedW4G39Cpi4YNVLcq+T0ubMGe64tAIBElHaF+o0tveTCEGZ0cq9DFBu99TC//zt8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=c922Fdun; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="c922Fdun" Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46462sQt011027; Thu, 4 Jul 2024 13:17:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= Td34kuM3qqzIOYsfY8JpJx+dFLGELeyixWok5GFe3HY=; b=c922FdunM1wwmDRm fa41BjrvjHv1TGv4iSiPZns/IxiOHI7VJplijwN843beaaoURFjfC4Ni8NRtnSFZ vIlxa/Izt+IQUcPCEoJuOQGMtozH6QayEgwsdE5nlIXlfgs8KxyJlIEOKngMJzMf kl8Wj/57cblTseyvR5aWtSsNq7tZa5gB+SNyuGc9QqaZf9GeXR+XsuXEPNzeWEnm JjVBwIZ90Q6tlMWcsoySCiLkfhpOZs/W5uSeTI/RnxV3TeoyKm1stPquRYiKAt8i dCBNDWT7jyj7055lhJ1Nl6qcCOOWwJAg7UlsvSfOhEtwQRZ996vrIpM0dVpnKWML MkwrhA== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 404yr9btef-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Jul 2024 13:17:21 +0000 (GMT) Received: from nasanex01a.na.qualcomm.com (nasanex01a.na.qualcomm.com [10.52.223.231]) by NASANPPMTA04.qualcomm.com (8.17.1.19/8.17.1.19) with ESMTPS id 464DHKjO001619 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 4 Jul 2024 13:17:20 GMT Received: from [10.253.9.70] (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Thu, 4 Jul 2024 06:17:19 -0700 Message-ID: <4ecbe215-6b73-48ea-8e8d-831e3682754c@quicinc.com> Date: Thu, 4 Jul 2024 21:17:16 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 4/5] devres: Simplify devm_percpu_match() implementation To: Greg KH CC: , , , , , References: <1719931914-19035-1-git-send-email-quic_zijuhu@quicinc.com> <1719931914-19035-5-git-send-email-quic_zijuhu@quicinc.com> <2024070424-deplete-dangling-bcc6@gregkh> Content-Language: en-US From: quic_zijuhu In-Reply-To: <2024070424-deplete-dangling-bcc6@gregkh> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01a.na.qualcomm.com (10.52.223.231) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: bWc8oQE6w9HxwK7nfAXjJ-LTJKtOOuGm X-Proofpoint-ORIG-GUID: bWc8oQE6w9HxwK7nfAXjJ-LTJKtOOuGm X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-04_09,2024-07-03_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 clxscore=1015 bulkscore=0 impostorscore=0 malwarescore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 lowpriorityscore=0 priorityscore=1501 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2407040094 On 7/4/2024 6:34 PM, Greg KH wrote: > On Tue, Jul 02, 2024 at 10:51:53PM +0800, Zijun Hu wrote: >> Simplify devm_percpu_match() implementation by removing redundant >> conversions. >> >> Signed-off-by: Zijun Hu >> --- >> Previous discussion link: >> https://lore.kernel.org/lkml/1719496036-24642-1-git-send-email-quic_zijuhu@quicinc.com/ >> >> Changes since the original one: >> - Select the simplier solution >> >> drivers/base/devres.c | 5 ++--- >> 1 file changed, 2 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/base/devres.c b/drivers/base/devres.c >> index e9b0d94aeabd..2ad6dacb3472 100644 >> --- a/drivers/base/devres.c >> +++ b/drivers/base/devres.c >> @@ -1176,9 +1176,8 @@ static void devm_percpu_release(struct device *dev, void *pdata) >> >> static int devm_percpu_match(struct device *dev, void *data, void *p) >> { >> - struct devres *devr = container_of(data, struct devres, data); >> - >> - return *(void **)devr->data == p; >> + /* @data is already and must be (void *)devr->data */ >> + return *(void **)data == p; > > The compiler output should be identical here, right? And container_of() yes, you are right. > enforces the placement so I'd prefer the original here as a comment > isn't going to enforce anything :) > i would like to show 2 different points related to the comments below: 1) the comments is applicable for *ALL* kinds of devres match()s, and is *NOT* specific to devm_percpu_match() and also does *NOT* enforce anything. may i remove the comments? 2) the original implementation is *NOT* normative as explained below: include/linux/device.h: typedef int (*dr_match_t)(struct device *dev, void *res, void *match_data); void *devres_find(struct device *dev, dr_release_t release, dr_match_t match, void *match_data); devres API users maybe need to write their match() functions, for example, user of API devres_find(), but struct devres is a devres internal implementation defined within devres.c and is *NOT* exposed to API user by device.h, so API user should not use struct devres when implement their devres match() normally. but original devm_percpu_match() uses the struct devres. > thanks, > > greg k-h