Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3028354pxa; Tue, 18 Aug 2020 04:54:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzpqiTm7Co1VBUVIxz7ZFuZryDIRRPbwVcZX5V9KKnT7Dv0aBUgXo039Y6dYSQYKUZD2oI X-Received: by 2002:a17:906:4696:: with SMTP id a22mr19484460ejr.154.1597751650047; Tue, 18 Aug 2020 04:54:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597751650; cv=none; d=google.com; s=arc-20160816; b=FlorcgMd50QW1zVeoe86R8j6o5n9LhJ+ESH4LXH8KYCAAREVrQcajlxLgKaxIXz/bl uV4G+loCpy1EfwrhNG27OZwcHtObcJnEvO+FSlqv2vBSKOFl9/z3mc2sabsCVodjjaI9 Rermj8IyChXW/+vYU3HLfuZDIZvw8qydTpbEuMPq/Z9o1gGniwbaVVNTozzNTCoc9XHY uEsZlB9UDQXcwK2TXCy+m3GiYcNc4Wil+kkCbNNelvkmLdV48fo9D0bcA6bjkVso/v1R s6gWrDngjQpprUAr4nFLavBRi+IlOsEbRuBvCAnZaCOKWz3lafu6mmNnWiTmn2k0MVgL xg1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Z/6TzKi6P4K3PlKCGwcBk/E/NFxRaUyEBrhst+wEBvk=; b=dos2ZbsiQ8Zv5QA8Qzl+IYFNroALjy4p+ED49RhCybjxx7SKywE+DtBHK+zAZYKSFx F6WOVunSjsG8AZZdfleqnxilbY369UirrUAUzPk1yOWIuIOGvhkkPqwBXYaVSuNXZh7W G/+FIkrrnIoF0QYU/r49TFF4JI6DSasM5XE1f8raOZudUpDKZSX4k3Ce9B3gTGR1Rzl2 LcHNIr3O1nYH+fENhsRxoMBQumVdxH2NSC0fGBUeCrCQiTFINCpHXks2r32KJuzy0C7A ZePest1AhyVpE+xcziZN05zhQ4km95p8Hvo/ltu44KlCdBnQpJIvxy+Y6z3S/6LseIeR eIww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EdiKSbZj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lv4si13035099ejb.604.2020.08.18.04.53.46; Tue, 18 Aug 2020 04:54:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EdiKSbZj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726706AbgHRLwA (ORCPT + 99 others); Tue, 18 Aug 2020 07:52:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:54658 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726353AbgHRLv6 (ORCPT ); Tue, 18 Aug 2020 07:51:58 -0400 Received: from kernel.org (unknown [87.70.91.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 034932075E; Tue, 18 Aug 2020 11:51:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597751517; bh=V6zWYb60MNl5LiY+q8W9QZ7ZvQ5dlxEVJ0ia/eFZhOc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=EdiKSbZj6yupVmUP+5fgsTfrtgHsXTtYGQPZhK0G3omTz9/YKqeHIIHQLPBMHEdSQ 5dKAsH8xPi+rdLUQW0npUmLUMS/ryx/nh+pzlI+uc3OpzrNKpOL0XN8SoaoezTn7B8 cgbqmLJSwKXwQfA9Xib/PN269LIn3jo72JuPsQJk= Date: Tue, 18 Aug 2020 14:51:41 +0300 From: Mike Rapoport To: Jarkko Sakkinen Cc: Ingo Molnar , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andi Kleen , Masami Hiramatsu , Peter Zijlstra , "Naveen N. Rao" , Anil S Keshavamurthy , "David S. Miller" , Jessica Yu , Ard Biesheuvel Subject: Re: [PATCH v5 5/6] kprobes: Use text_alloc() and text_free() Message-ID: <20200818115141.GO752365@kernel.org> References: <20200724050553.1724168-1-jarkko.sakkinen@linux.intel.com> <20200724050553.1724168-6-jarkko.sakkinen@linux.intel.com> <20200724092746.GD517988@gmail.com> <20200725031648.GG17052@linux.intel.com> <20200726081408.GB2927915@kernel.org> <20200818053029.GE44714@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200818053029.GE44714@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 18, 2020 at 08:30:29AM +0300, Jarkko Sakkinen wrote: > On Sun, Jul 26, 2020 at 11:14:08AM +0300, Mike Rapoport wrote: > > > > > > I'm not still sure that I fully understand this feedback as I don't see > > > any inherent and obvious difference to the v4. In that version fallbacks > > > are to module_alloc() and module_memfree() and text_alloc() and > > > text_memfree() can be overridden by arch. > > > > The major difference between your v4 and my suggestion is that I'm not > > trying to impose a single ARCH_HAS_TEXT_ALLOC as an alternative to > > MODULES but rather to use per subsystem config option, e.g. > > HAVE_KPROBES_TEXT_ALLOC. > > > > Another thing, which might be worth doing regardless of the outcome of > > this discussion is to rename alloc_insn_pages() to text_alloc_kprobes() > > because the former is way too generic and does not emphasize that the > > instruction page is actually used by kprobes only. > > What if we in kernel/kprobes.c just: > > #ifndef CONFIG_ARCH_HAS_TEXT_ALLOC I don't think that CONFIG_ARCH_HAS_TEXT_ALLOC will work for all architectures. If an architecture has different restrictions for allocation of text for, say, modules, kprobes, bfp, it won't be able to use a single ARCH_HAS_TEXT_ALLOC. Which means that this architecture is stuck with dependency of kprobes on MODULES until the next rework. > void __weak *alloc_insn_page(void) > { > return module_alloc(PAGE_SIZE); > } > > void __weak free_insn_page(void *page) > { > module_memfree(page); > } > #endif > > In Kconfig (as in v5): > > config KPROBES > bool "Kprobes" > depends on MODULES || ARCH_HAS_TEXT_ALLOC > > I checked architectures that override alloc_insn_page(). With the > exception of x86, they do not call module_alloc(). > > If no rename was done, then with this approach a more consistent. > config flag name would be CONFIG_ARCH_HAS_ALLOC_INSN_PAGE. > > I'd call the function just as kprobes_alloc_page(). Then the > config flag would become CONFIG_HAS_KPROBES_ALLOC_PAGE. > > > -- > > Sincerely yours, > > Mike. > > Thanks for the feedback! > > /Jarkko -- Sincerely yours, Mike.