Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp3327316pxb; Thu, 10 Feb 2022 18:46:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJxF32m0xwooh7CyrgjElTedyesJocXzD2e7itmnza30CwovV1yv6j+/c3gDNtCKiRYz562U X-Received: by 2002:a65:4c87:: with SMTP id m7mr8509315pgt.509.1644547619476; Thu, 10 Feb 2022 18:46:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644547619; cv=none; d=google.com; s=arc-20160816; b=Ju6Dz7CJRvw1t+n5Xnua4UjBI3z204uSaYFMlKMr6XQmb5EXj6iyd2tO2pLeTqBwut HqT0Sjrn4gwIYuKz1nuODcnch+K8YVbGwITS78XArLcCktqs4xqYvs3a06+K81QB7CoW oxNoeC6Y+nZEbqtG3yCMJvNMDJr8HqJBrRnWHNa2guiLs4S6k8sHEVk/eU9LSeGJZtc/ 26PrTzMyfwPECheou9ZLSP0HGljnbIP8s6KlqWXm4HhmFwSev2zgO6aLRhzluzp3LIdw vx78QS32POoNSdrukXQBqNqvva/9XY07dNGngfw8d+fjiqDB+wZnlVvE6oy1QsWXXTeL 2KKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date; bh=VfutGFnqpIBSKwSsx1OWySiM17sNtQ1GwTG/k62LPZw=; b=zWha6ciiuyeDHvklIm7pUL1/OGijQhWQFdR8OV8fGcpacu+HOoa8y1afZos+DRJE5t 66yKKuuruHiUQJOx7e7NR/FJoIFnGKDiUv2Qb8Cv6ha0T/wLCVpVjpwlnXk970jAL6Pg qGA0dqLGlsHtUSmnYNYo75sWH+epMMmJl6s7TIcWbYAKmeVWxHNcEgjV41bGwRkDBcNt qIM4gVfnoFjyTlSJu4CUXqios1pD1q5WDoNMnMCwvGBxwzVDRr4kLP8hs5L36o9GOfGJ u9E3NheThP1UIHBaA/n4a+ol9WgRP+iCL0tenZBG0LeA81opYMFjmSOwLIbZ07tfUavB OxSg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q11si3113046pla.383.2022.02.10.18.46.47; Thu, 10 Feb 2022 18:46:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244143AbiBKCc0 (ORCPT + 99 others); Thu, 10 Feb 2022 21:32:26 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:56028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347425AbiBKCcZ (ORCPT ); Thu, 10 Feb 2022 21:32:25 -0500 Received: from out30-42.freemail.mail.aliyun.com (out30-42.freemail.mail.aliyun.com [115.124.30.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 782415FCD; Thu, 10 Feb 2022 18:32:20 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R741e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04395;MF=tonylu@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0V46drYP_1644546737; Received: from localhost(mailfrom:tonylu@linux.alibaba.com fp:SMTPD_---0V46drYP_1644546737) by smtp.aliyun-inc.com(127.0.0.1); Fri, 11 Feb 2022 10:32:18 +0800 Date: Fri, 11 Feb 2022 10:32:16 +0800 From: Tony Lu To: Wen Gu Cc: kgraul@linux.ibm.com, davem@davemloft.net, kuba@kernel.org, linux-s390@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net] net/smc: Avoid overwriting the copies of clcsock callback functions Message-ID: Reply-To: Tony Lu References: <1644415853-46641-1-git-send-email-guwen@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham 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 Thu, Feb 10, 2022 at 04:56:00PM +0800, Wen Gu wrote: > > > On 2022/2/10 10:50 am, Tony Lu wrote: > > > I am wondering that there is a potential racing. If ->use_fallback is > > setted to true, but the rest of replacing process is on the way, others > > who tested and passed ->use_fallback, they would get old value before > > replacing. > > > > Thanks for your comments. > > I understand your concern. But when I went through all the places that > check for smc->use_fallback, I haven't found the exact potential racing > point. Please point out if I missed something. Thank you. > > In my humble opinion, most of the operations after smc->use_fallback check > have no direct relationship with what did in smc_switch_to_fallback() (the > replacement of clcsock callback functions), except for which in smc_sendmsg(), > smc_recvmsg() and smc_sendpage(): > > smc_sendmsg(): > > if (smc->use_fallback) { > rc = smc->clcsock->ops->sendmsg(smc->clcsock, msg, len); > } > > smc_recvmsg(): > > if (smc->use_fallback) { > rc = smc->clcsock->ops->recvmsg(smc->clcsock, msg, len, flags); > } > > smc_sendpage(): > > if (smc->use_fallback) { > rc = kernel_sendpage(smc->clcsock, page, offset, > size, flags); > } > > If smc->use_fallback is set to true, but callback functions (sk_data_ready ...) > of clcsock haven't been replaced yet at this moment, there may be a racing as > you described. > > But it won't happen, because fallback must already be done before sending and receiving. > > What do you think about it? > I am concerning about the non-blocking work in workqueue. If we can make sure the order of fallback is determined, it would be safe. From your analysis, I think it is safe for now. Let's back to the patch, the original version of switch_to_fallback() has a implicit reentrant semantics. This fixes should work, thanks. Thanks for your detailed investigation. Best regards, Tony Lu