Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10761821imu; Thu, 6 Dec 2018 06:26:04 -0800 (PST) X-Google-Smtp-Source: AFSGD/UTHOrV1RYxnM8Cw5h6dX8HLV1jtAlKaOGmi2/3l1sPzu/KkfUfdomvjRR+AUYmzUBmLsY7 X-Received: by 2002:a17:902:a40f:: with SMTP id p15mr29121679plq.286.1544106364696; Thu, 06 Dec 2018 06:26:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544106364; cv=none; d=google.com; s=arc-20160816; b=Dlxyg1aZH1hOCOR5yY5KNXKqyvtbwlePgdSo2bM1VqW6w7f1HwyBU3xhFQHJcVd7cv pgvSlFQhAYgRoU9EoDZWwrrOsPBLhGoC+7IWBJKSo0cGSUvv4J4eetWKey15WiV4TTn8 cskYO+wutGBrcQ3Cxf4tscuUFsfzgtn2VyySyB4ONTCjlaEZDig520CL6Gpgh8LUcD5a RSWM4gY5XW4kn+h5hdrAF/JWXjC7GdVQsXXWFgmEdrlhP+mDc/bq07DfPcXspOqgNCt/ OUWcrpChcWCMDbt025Qa6raLhs3PrpdrZk0MtQ0ExiOgbM8EuOSBHWQCS4nxXOhl8p4K /4Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject; bh=l7oag/C5DCnBWKVlR8N3emZ/wQIGYH6/wjyfOFWI/Pc=; b=iF76dPyKl57pNXlZA+OJ2Trkywk5iv61Dw3xAoizpdrFlA5BMSTl1TF0PFz6SCYFg6 qpd+BKqLIDOcSNcBjW4qh90/+ZzYChrVloaxRDCPQwZvjOOAA+YtlelcfpolB6iiAaTV GJvnTcXzBGvjdvf6mTVltd/jpgKtGTwzNO/pZXVZN4Znd1hqmdsQfGXQ68uZoII6RHyn neZqBCKgEIN72qhlSsbzs8Cs5tTnngyySQq/zg4EAICENlo0ikpvq1+Lp0wNuLsVoMa7 jttKVNZhgnGG8mEspe6+k8cz9BSGs0ePLlSvhxxYiqjnuOJ2vm0N1WAlr7cDA/O1fN46 vK/A== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f21si386420pgv.111.2018.12.06.06.25.14; Thu, 06 Dec 2018 06:26:04 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729638AbeLFOXt (ORCPT + 99 others); Thu, 6 Dec 2018 09:23:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53034 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727704AbeLFOXt (ORCPT ); Thu, 6 Dec 2018 09:23:49 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 27C4D3DE; Thu, 6 Dec 2018 14:23:49 +0000 (UTC) Received: from jlaw-desktop.bos.csb (dhcp-17-208.bos.redhat.com [10.18.17.208]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2FABB5D96F; Thu, 6 Dec 2018 14:23:48 +0000 (UTC) Subject: Re: [PATCH v14 03/11] livepatch: Consolidate klp_free functions To: Petr Mladek Cc: Jiri Kosina , Josh Poimboeuf , Miroslav Benes , Jason Baron , Evgenii Shatokhin , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, Jessica Yu References: <20181129094431.7801-1-pmladek@suse.com> <20181129094431.7801-4-pmladek@suse.com> <20181205190220.vterzx33opvvijne@redhat.com> <20181206081501.jkki7hg4u43fqwth@pathway.suse.cz> From: Joe Lawrence Organization: Red Hat Message-ID: Date: Thu, 6 Dec 2018 09:23:47 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: <20181206081501.jkki7hg4u43fqwth@pathway.suse.cz> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 06 Dec 2018 14:23:49 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/06/2018 03:15 AM, Petr Mladek wrote: > On Wed 2018-12-05 14:02:20, Joe Lawrence wrote: >> On Thu, Nov 29, 2018 at 10:44:23AM +0100, Petr Mladek wrote: >>> The code for freeing livepatch structures is a bit scattered and tricky: >>> >>> [ ... snip ... ] >>> >>> +static int klp_init_patch(struct klp_patch *patch) >>> +{ >>> + struct klp_object *obj; >>> + int ret; >>> + >>> + mutex_lock(&klp_mutex); >>> + >>> + ret = klp_init_patch_before_free(patch); >>> if (ret) { >>> mutex_unlock(&klp_mutex); >>> return ret; >>> } >>> >> >> I believe klp_init_patch_before_free() accumulates more responsibilities >> later in the patchset, but I'll ask here: does it really need the >> klp_mutex since it looks to be operating only on the klp_patch, its >> objects and functions? > > I do not have a strong opinion about it. > > On one hand, we are manipulating all the structures and should prevent > any parallel use. On the other hand, the rest of the code will not > touch the patch until it is added into klp_patches list or until > the sysfs interface is created. > > If you think that it might cause false expectations and confusions > then I could move it out of the lock. I didn't find it confusing, nor is it performance limiting. I figured I would point it out in case there was some reason for the mutex that I had missed. > Well, in the final version we need to call klp_check_patch_conflict() > under the mutex. That's right. -- Joe