From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F483C433F5 for ; Sat, 16 Apr 2022 17:42:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9A7FD6B0072; Sat, 16 Apr 2022 13:42:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 958006B0073; Sat, 16 Apr 2022 13:42:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7F8A96B0074; Sat, 16 Apr 2022 13:42:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0058.hostedemail.com [216.40.44.58]) by kanga.kvack.org (Postfix) with ESMTP id 723746B0072 for ; Sat, 16 Apr 2022 13:42:44 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 2A29EA62FC for ; Sat, 16 Apr 2022 17:42:44 +0000 (UTC) X-FDA: 79363462248.30.F97CBD9 Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) by imf30.hostedemail.com (Postfix) with ESMTP id 9A59B80008 for ; Sat, 16 Apr 2022 17:42:43 +0000 (UTC) Received: by mail-lf1-f41.google.com with SMTP id bu29so18559113lfb.0 for ; Sat, 16 Apr 2022 10:42:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/jIUvFDPrhPXkkJF0Dp/55PJ5S0x4qstps2XI7eQ/M0=; b=YYzhPBou87optH724QK2IXpfqNyBE5k1bdRrq/6iVqz4j33fCs6gu77SZiD7uZ+/+y AyATSsUlQqmOxbDT/VFiodyniyPPS5dBwPFqxHjJltJ+4vFWCe6ZmMLgBqAp59zNbOWl mVLQQZ6sTlPDIsn1CrMHr8Rynu32DMPkzsZDw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/jIUvFDPrhPXkkJF0Dp/55PJ5S0x4qstps2XI7eQ/M0=; b=VYJRbAFX2dBcPyxTWIMc3BRg/Il8vkDqpJEp9ztY4zUHQGM3UzycMwCyfbNNfU0Ee0 JxzQPidCvglBXDA2PvX7VJgBSFnsqbsEvPHlrs/J4nES4JhWZzcNULLuwemJCcVveUXH 2ZOrFyoYEezWBuJa3kXpfMcWxdnafMk3kwkqZ9mBN5AeWO0d7a/xAZl2ry8eYYRPLY// w64elOn0VKfuuMqEOEBb1MuUFtiPdExwqLf0xR4QeC76m22NSCU4t5QvJVGRyhdIRg9f 3WlOdMdOrGKrYuV7O/8nbUUmUtWRgpvg2hukTot8dRv2gYnl7gFmC4MFfY4ngGzps2v+ THNA== X-Gm-Message-State: AOAM530DTnl3+sQqJPM4ZTorFT9O/lHkjLiTYrECzaQTVdL544Pk/dvt p9a8vVc5+J1ZeXK23lCBpCoxfkaIgYKEps5Yi5I= X-Google-Smtp-Source: ABdhPJzZTOcijK8mqcON/uEa8CkF7H3ZgC1a++3qxlwssfWzcey4ae5ZfUprmkj8vgoSaBEIe8k1KQ== X-Received: by 2002:ac2:5964:0:b0:46d:40f9:604c with SMTP id h4-20020ac25964000000b0046d40f9604cmr3004971lfp.496.1650130961645; Sat, 16 Apr 2022 10:42:41 -0700 (PDT) Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com. [209.85.167.42]) by smtp.gmail.com with ESMTPSA id p27-20020a19f11b000000b0046ce6a15b16sm721887lfh.149.2022.04.16.10.42.39 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 16 Apr 2022 10:42:40 -0700 (PDT) Received: by mail-lf1-f42.google.com with SMTP id o2so18424424lfu.13 for ; Sat, 16 Apr 2022 10:42:39 -0700 (PDT) X-Received: by 2002:a05:6512:2291:b0:46b:b72b:c947 with SMTP id f17-20020a056512229100b0046bb72bc947mr2938719lfu.531.1650130959084; Sat, 16 Apr 2022 10:42:39 -0700 (PDT) MIME-Version: 1.0 References: <20220414191240.9f86d15a3e3afd848a9839a6@linux-foundation.org> <20220415021328.7D31EC385A1@smtp.kernel.org> <29b9ef95-1226-73b4-b4d1-6e8d164fb17d@gmail.com> In-Reply-To: From: Linus Torvalds Date: Sat, 16 Apr 2022 10:42:22 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [patch 02/14] tmpfs: fix regressions from wider use of ZERO_PAGE To: Borislav Petkov Cc: Mark Hemment , Andrew Morton , "the arch/x86 maintainers" , Peter Zijlstra , patrice.chotard@foss.st.com, Mikulas Patocka , Lukas Czerner , Christoph Hellwig , "Darrick J. Wong" , Chuck Lever , Hugh Dickins , patches@lists.linux.dev, Linux-MM , mm-commits@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 9A59B80008 X-Stat-Signature: 4rkk7jssf396zaq1jish9myaitr14p7z Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=google header.b=YYzhPBou; dmarc=none; spf=pass (imf30.hostedemail.com: domain of torvalds@linuxfoundation.org designates 209.85.167.41 as permitted sender) smtp.mailfrom=torvalds@linuxfoundation.org X-HE-Tag: 1650130963-832948 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sat, Apr 16, 2022 at 10:28 AM Borislav Petkov wrote: > > you also need a _fsrm() one which checks X86_FEATURE_FSRM. That one > should simply do rep; stosb regardless of the size. For that you can > define an alternative_call_3 similar to how the _2 variant is defined. Honestly, my personal preference would be that with FSRM, we'd have an alternative that looks something like asm volatile( "1:" ALTERNATIVE("call __stosb_user", "rep movsb", X86_FEATURE_FSRM) "2:" _ASM_EXTABLE_UA(1b, 2b) :"=c" (count), "=D" (dest),ASM_CALL_CONSTRAINT :"0" (count), "1" (dest), "a" (0) :"memory"); iow, the 'rep stosb' case would be inline. Note that the above would have a few things to look out for: - special 'stosb' calling convention: %rax/%rcx/%rdx as inputs %rcx as "bytes not copied" return value %rdi can be clobbered so the actual functions would look a bit odd and would need to save/restore some registers, but they'd basically just emulate "rep stosb". - since the whole point is that the "rep movsb" is inlined, it also means that the "call __stosb_user" is done within the STAC/CLAC region, so objdump would have to be taught that's ok but wouldn't it be lovely if we could start moving towards a model where we can just inline 'memset' and 'memcpy' like this? NOTE! The above asm has not been tested. I wrote it in this email. I'm sure I messed something up. Linus