Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp887884ybl; Fri, 31 Jan 2020 09:45:32 -0800 (PST) X-Google-Smtp-Source: APXvYqwZFEgqv3rxDf5bDqDrkAtU4ANG9iuWmiycTygEKvpY6Z153WZwPGyKCipiEtGy+vlo8uPa X-Received: by 2002:aca:c551:: with SMTP id v78mr7164973oif.161.1580492732642; Fri, 31 Jan 2020 09:45:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580492732; cv=none; d=google.com; s=arc-20160816; b=XxGdcMKNKSpIc1NS67WzyBSumj6xDf7bbHsvactskquE0OJtRxLrfqVSVfZhCWH4HC JFxPIDrIaft19zB+zjx2SSA2qiLVBLaXyrOVaLHbFwwAflFw0DaBMkBlI2qieS7/+PiC 7JULdJOgIELXZBAhMPcKqleGpbWdj1va1ew6PhrZ2CU7CoPYk4ybogF9GXxKhUMDQ5Zu HHk7DvT1AD2gg3Y5PpzvrMzMlxzdE9vs27NmcKov5FFcWXnqJ5Da0Z5SuLvcfJ/vvNa0 U0DhEA+dfdl8TZhLoEQQe8QEBC6w0AYF5gm+f4e+YW6ngMqyAvN60DDhDvWe4/0OYa+o 33ZQ== 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:from:references:cc:to:subject; bh=URFOs2t7XKi95ORUTSh+7uwagD+qAIuLWAzGeVFZpNc=; b=o58DNuyQlavE1LS5kouvuM2R6MTgsThvlpsc0UehP4reu/LqPyO8omclquUNA2dvc8 4biQva0L3KQr5Wr3DVbl8uCECl5Vhc4B9Ae1Z5OesRkcUJpFRXisYyzIqsHi9KihHLmU hAhidinaNR6x/X3ollcz9kvwHctnjbR4Aok11WV6t7FDk6gdc5wSyiVZA1/SBa95UgRF 3tr1Hy3iv0yUys3SBkb4D2YU54ly/9g0YOw/Ala9GlkPB1OwYxueHaAK4tmYw7ZeqyFX JatXH6gkP2Rq8Gb+hRzvCNDuheJwMo8WohTy8uOZl/keBDyGDRTf6+hsVDOm0ITGpw7A cB7Q== 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 73si4525218oii.60.2020.01.31.09.45.20; Fri, 31 Jan 2020 09:45:32 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727128AbgAaRnv (ORCPT + 99 others); Fri, 31 Jan 2020 12:43:51 -0500 Received: from foss.arm.com ([217.140.110.172]:37882 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726712AbgAaRnv (ORCPT ); Fri, 31 Jan 2020 12:43:51 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C78FAFEC; Fri, 31 Jan 2020 09:43:50 -0800 (PST) Received: from [10.1.196.37] (e121345-lin.cambridge.arm.com [10.1.196.37]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DF0873F68E; Fri, 31 Jan 2020 09:43:49 -0800 (PST) Subject: Re: [PATCH] dma-debug: dynamic allocation of hash table To: Eric Dumazet Cc: Christoph Hellwig , Joerg Roedel , iommu@lists.linux-foundation.org, Eric Dumazet , Geert Uytterhoeven , linux-kernel References: <20200130191049.190569-1-edumazet@google.com> From: Robin Murphy Message-ID: <62e1ee46-ad9e-988f-a2a3-8fd217e28f24@arm.com> Date: Fri, 31 Jan 2020 17:43:45 +0000 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 31/01/2020 2:42 pm, Eric Dumazet wrote: > On Fri, Jan 31, 2020 at 4:30 AM Robin Murphy wrote: >> >> ...and when that represents ~5% of the total system RAM it is a *lot* >> less reasonable than even 12KB. As I said, it's great to make a debug >> option more efficient such that what it observes is more representative >> of the non-debug behaviour, but it mustn't come at the cost of making >> the entire option unworkable for other users. >> > > Then I suggest you send a patch to reduce PREALLOC_DMA_DEBUG_ENTRIES > because having 65536 preallocated entries consume 4 MB of memory. ...unless it's overridden on the command-line ;) > Actually this whole attempt to re-implement slab allocations in this > file is suspect. Again that's a matter of expected usage patterns - typically the "reasonable default" or user-defined preallocation should still be enough (as it *had* to be before), and the kind of systems that can sustain so many live mappings as to regularly hit the dynamic expansion path are also likely to have enough memory not to care that later-unused entries never get 'properly' freed back to the kernel (plus as you've observed, many workloads tend to reach a steady state where entries are mostly only transiently free anyway). The reasoning for the exact implementation details is there in the commit logs. > Do not get me wrong, but if you really want to run linux on a 16MB host, > I guess you need to add CONFIG_BASE_SMALL all over the places, > not only in this kernel/dma/debug.c file. Right, nobody's suggesting that defconfig should "just work" on your router/watch/IoT shoelaces/whatever, I'm just saying that tuning any piece of common code for datacenter behemoths, for quality-of-life rather than functional necessity, and leaving no way to adjust it other than hacking the source, would represent an unnecessary degree of short-sightedness that we can and should avoid. Taking a closer look at the code, it appears fairly straightforward to make the hash size variable, and in fact making it self-adjusting doesn't seem too big a jump from there. I'm happy to have a go at that myself if you like. Robin.