Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp751641ybg; Mon, 1 Jun 2020 13:30:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIimJtWNdfRAc1qDyxAVYmeZs+VP73kMOA4nwL7a4nGVEH5J1pl6kjetce2oIUxhb4k1MM X-Received: by 2002:a17:906:6686:: with SMTP id z6mr15210252ejo.258.1591043436877; Mon, 01 Jun 2020 13:30:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591043436; cv=none; d=google.com; s=arc-20160816; b=RxjesY8qQML+u7MMA66yBNgidpXu4sDTp8OAVyPZr6lPdqsbNBvYjRWInGyMOYkkVw 2mpl6sBM69yZMJGtaP15y7F2Y1YHH2nV2oIggdO/3+dcibt+QjG+G6W03KGaUUB3UkL+ 1VKMeA12visgXgB2fi6cFjGEtuUhngLb7BttazOm2XBrFYyiN5iinCDLwNU4neqbhbLr BOKRqE9edVaQWQdgxxkTd0E7gznmbRLy5h0Jh3CPoQNn6CbzOL2h2TdjFmaH3LW9FqJv KkW42HTt+wdtPje9AQ9GFZ1AeSPwxMycJqEBqp7qR8Svb/+IbzphuSwQnFeFMEn6TT/W SvxA== 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:mime-version :user-agent:cc:to:from:subject:date:references:in-reply-to :message-id; bh=+8ITo7JB9dPZsN0tmkVSLVxHBKJTl8gwJ9QLj04WrkM=; b=aGz6keyFigTLssLA+eC999nRLZmF9IP4VQ8M1YTcqIClwz00NTe4n1/ooqG+UF43BI CcZPuzddsUldkV8GkK2AyCnvI5X19o3MKVWn/D568mijbbFZ8osl4juca8hezO8WQXOR l8yLPAXQAvc5P8jTMaPMON91PufvihrsGn+AE2YLmvkEGiY11lyAfQ179+0ehlPQ6q/3 aUqzPID5K54F/GUFrvkSNo8gVrKwEc7jK37jMttqgsof6BkF31FtPIL2uMrZdpur3+Ha WQ4hEQmuB0aKOMPdDLn6zjgisYRB2SgM+r17Wy+8LUUHN4AO/aPdx/ztISE+eruR6CNw Lo/Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b16si291860edj.295.2020.06.01.13.30.14; Mon, 01 Jun 2020 13:30:36 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728097AbgFAU0N (ORCPT + 99 others); Mon, 1 Jun 2020 16:26:13 -0400 Received: from outpost1.zedat.fu-berlin.de ([130.133.4.66]:34471 "EHLO outpost1.zedat.fu-berlin.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726944AbgFAU0N (ORCPT ); Mon, 1 Jun 2020 16:26:13 -0400 Received: from inpost2.zedat.fu-berlin.de ([130.133.4.69]) by outpost.zedat.fu-berlin.de (Exim 4.93) with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (envelope-from ) id 1jfr0b-0028M4-7d; Mon, 01 Jun 2020 22:26:09 +0200 Received: from webmail1.zedat.fu-berlin.de ([130.133.4.91] helo=webmail.zedat.fu-berlin.de) by inpost2.zedat.fu-berlin.de (Exim 4.93) with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (envelope-from ) id 1jfr0a-000TkQ-S2; Mon, 01 Jun 2020 22:26:09 +0200 Received: from 92.201.26.143 (ZEDAT-Webmail authenticated user mkarcher) by webmail.zedat.fu-berlin.de with HTTP; Mon, 1 Jun 2020 22:26:09 +0200 Message-ID: <50235.92.201.26.143.1591043169.webmail@webmail.zedat.fu-berlin.de> In-Reply-To: <20200601165700.GU1079@brightrain.aerifal.cx> References: <20200529174540.4189874-1-glaubitz@physik.fu-berlin.de> <20200529174540.4189874-2-glaubitz@physik.fu-berlin.de> <2ad089c1-75cf-0986-c40f-c7f3f8fd6ead@physik.fu-berlin.de> <20200601030300.GT1079@brightrain.aerifal.cx> <20200601165700.GU1079@brightrain.aerifal.cx> Date: Mon, 1 Jun 2020 22:26:09 +0200 Subject: Re: [PATCH] sh: Implement __get_user_u64() required for 64-bit get_user() From: "Michael Karcher" To: "Rich Felker" Cc: "John Paul Adrian Glaubitz" , "Geert Uytterhoeven" , "Linux-sh list" , "Yoshinori Sato" , "Michael Karcher" , "Linux Kernel Mailing List" User-Agent: ZEDAT-Webmail MIME-Version: 1.0 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: 8bit X-Originating-IP: 130.133.4.91 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Rich Felker schrieb: >> >> Can I propose a different solution? For archs where there isn't >> >> actually any 64-bit load or store instruction, does it make sense to >> >> be writing asm just to do two 32-bit loads/stores, especially when >> >> this code is not in a hot path? >> > Yes, that's an option, too. >> That's the solution that Michael Karcher suggested to me as an >> alternative when I talked to him off-list. There is a functional argument agains using get_user_32 twice, which I overlooked in my private reply to Adrian. If any of the loads fail, we do not only want err to be set to -EFAULT (which will happen), but we also want a 64-bit zero as result. If one 32-bit read faults, but the other one works, we would get -EFAULT together with 32 valid data bits, and 32 zero bits. I continue to elaborate on my performance remark, ignoring this functional difference (which is a good reason to not just use two 32-bit accesses, much more so than the performance "issue"). > I don't have an objection to doing it the way you've proposed, but I > don't think there's any performance distinction or issue with the two > invocations. Assuming we don't need two exception table entries (put_user_64 currently uses only one, maybe it's wrong), using put_user_32 twice creates an extra unneeded exception table entry, which will "bloat" the exception table. That table is most likely accessed by a binary search algorithm, so the performance loss is marginal, though. Also a bigger table size is cache-unfriendly. (Again, this is likely marginal again, as binary search is already extremely cache-unfriendly). A similar argument can be made for the exception handler. Even if we need two entries in the exception table, so the first paragraph does not apply, the two entries in the exception table can share the same exception handler (clear the whole 64-bit destination to zero, set -EFAULT, jump past both load instructions), so that part of (admittedly cold) kernel code can get some instructios shorter. Regards, Michael Karcher