Received: by 10.192.165.156 with SMTP id m28csp980119imm; Fri, 13 Apr 2018 11:08:02 -0700 (PDT) X-Google-Smtp-Source: AIpwx48ek6jwh1/UWKcjbj99awRF7l/JkIKK8OrcIbvN4twDntAuIugcAsVZSL/3SAejGaTBUT5L X-Received: by 10.98.205.69 with SMTP id o66mr12490866pfg.34.1523642882087; Fri, 13 Apr 2018 11:08:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523642882; cv=none; d=google.com; s=arc-20160816; b=gFt/tMhghGjNEuXVChNbo9ZYYGAz5bLNGsi5q5XHZzR4VFS3EUELw1qSOHz/PblkAq KCnupGGaN+ON6NIkkw6mHrcT+iO+PHcyaKL2+E6nIMuSkCrXnhauF7/SjeGZlH3UcMGH z6/qLFK3ExuMNMcJgRUp3oTJq0mK2bf9E1LO55bWU1mb0u6PcU7Q+zEs4332z0VQlJ0J T2Ehd0wgvuCq9PSfi1x7v6F/415ORMCgYwJuHgZ7ihsI9a+k+rhPRTr97Be58AjcsdM2 Nmygwh0761gYUSd4pov5EgbPMQUwdfA3/Y82mLNmAks/AuQG/9zzhpNxhF5/PG7vDY2s w4qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:arc-authentication-results; bh=CZZhjcyBbYCOgE8QkGiMWdeLBAmK8dpcX3K62TVDK/U=; b=QBrDto8w142w8/2HI/572UfO/oAYEMa/hAWuY0Nrd2XMvmncwV/vcLHMhRhmfq/DsX zOSVC6y4See4lQ9jWJ8GvUIEHN4Nhv8AUrnXO9tKFNIpBnj8i9hqfi4kX9CUgD5PVFb5 TLowd3JIuEWi4ehJwhZF6zQa1HHRRCgP4odacMe3fkEtbI6F9Yxe8MPluRDDNbROuQ2T fgWKhG0hPn+FrNTIK1yYA7a3dSJdmcTv2PV+slf04qwC30JBRQOpgzKgNXlWqCX8FmzW 0bqltroyCuXK70cxMshTiOsd2ji1KAeyEHY/spvxicBXX0qoHQgakQ9N/FdN7Njw+1OF H66A== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y191si4990095pfb.80.2018.04.13.11.07.47; Fri, 13 Apr 2018 11:08:02 -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; 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 S1751622AbeDMSGa (ORCPT + 99 others); Fri, 13 Apr 2018 14:06:30 -0400 Received: from mail.efficios.com ([167.114.142.138]:60774 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750849AbeDMSG3 (ORCPT ); Fri, 13 Apr 2018 14:06:29 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 5900C1B04FF; Fri, 13 Apr 2018 14:06:28 -0400 (EDT) Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail02.efficios.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id rnLMG7pT5KDd; Fri, 13 Apr 2018 14:06:27 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id C325D1B04FC; Fri, 13 Apr 2018 14:06:27 -0400 (EDT) X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail02.efficios.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Ne3qTDa9h5mA; Fri, 13 Apr 2018 14:06:27 -0400 (EDT) Received: from mail02.efficios.com (mail02.efficios.com [167.114.142.138]) by mail.efficios.com (Postfix) with ESMTP id A711B1B04F5; Fri, 13 Apr 2018 14:06:27 -0400 (EDT) Date: Fri, 13 Apr 2018 14:06:27 -0400 (EDT) From: Mathieu Desnoyers To: Linus Torvalds Cc: Peter Zijlstra , "Paul E. McKenney" , Boqun Feng , Andy Lutomirski , Dave Watson , linux-kernel , linux-api , Paul Turner , Andrew Morton , Russell King , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Andrew Hunter , Andi Kleen , Chris Lameter , Ben Maurer , rostedt , Josh Triplett , Catalin Marinas , Will Deacon , Michael Kerrisk Message-ID: <1111249972.9907.1523642787504.JavaMail.zimbra@efficios.com> In-Reply-To: References: <20180412192800.15708-1-mathieu.desnoyers@efficios.com> <20180412192800.15708-13-mathieu.desnoyers@efficios.com> <1580648199.9463.1523563167045.JavaMail.zimbra@efficios.com> <625160026.9658.1523621809662.JavaMail.zimbra@efficios.com> Subject: Re: [RFC PATCH for 4.18 12/23] cpu_opv: Provide cpu_opv system call (v7) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [167.114.142.138] X-Mailer: Zimbra 8.8.7_GA_1964 (ZimbraWebClient - FF52 (Linux)/8.8.7_GA_1964) Thread-Topic: cpu_opv: Provide cpu_opv system call (v7) Thread-Index: 3J9p2fnhryUrJjpLq6+QR1Ok8gmeVA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- On Apr 13, 2018, at 12:37 PM, Linus Torvalds torvalds@linux-foundation.org wrote: > On Fri, Apr 13, 2018 at 5:16 AM, Mathieu Desnoyers > wrote: >> The vmalloc space needed by cpu_opv is bound by the number of pages >> a cpu_opv call can touch. > > No it's not. > > You can have a thousand different processes doing cpu_opv at the same time. > > A *single* cpu_opv may me limited toi "only" a megabyte, but I'm not > seeing any global limit anywhere. > > In short, this looks like a guaranteed DoS approach to me. Right, so one simple approach to solve this is to limit to the number of concurrent cpu_opv executed at any given time. Considering that cpu_opv is a slow path, we can limit the number of concurrent cpu_opv executions by protecting this with a global mutex, or a semaphore if we want the number of concurrent executions to be greater than 1. Another approach if we want to be fancier is to keep track of the amount of vma address space currently used by all in-flight cpu_opv. Beyond a given threshold, further execution of additional cpu_opv instances would block, awaiting to be woken up when vmalloc address space is freed when in-flight cpu_opv complete. What global vmalloc address-space budget should we aim for ? Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com